blob: 051edf3461e88a1f0060fab5a7a2b8a38b2b0995 [file] [log] [blame]
Brian Silverman4a2409e2018-08-04 23:24:02 -07001[/
2 Copyright 2007 John Maddock.
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt).
6]
7
8[section:has_trivial_destructor has_trivial_destructor]
9 template <class T>
10 struct has_trivial_destructor : public __tof {};
11
12__inherit If T is a (possibly cv-qualified) type with a trivial destructor
13then inherits from __true_type, otherwise inherits from __false_type.
14
15If a type has a trivial destructor then the destructor has no effect:
16calls to the destructor can be safely omitted. Note that using meta-programming
17to omit a call to a single trivial-constructor call is of no benefit whatsoever.
18However, if loops and/or exception handling code can also be omitted, then some
19benefit in terms of code size and speed can be obtained.
20
21__compat Without some (as yet unspecified) help from the compiler,
22has_trivial_destructor will never report that a user-defined class or struct has a
23trivial destructor; this is always safe, if possibly sub-optimal.
24In addition, in order to correctly handle deleted or private destructors then
25support for C++11's `decltype` is required.
26Currently (June 2015) compilers more recent than Visual C++ 8, GCC-4.3, Greenhills 6.0,
27Intel-11.0, and Codegear have the necessary compiler __intrinsics to ensure that this
28trait "just works". You may also test to see if the necessary __intrinsics are available
29by checking to see if the macro `BOOST_HAS_TRIVIAL_DESTRUCTOR` is defined.
30
31
32__std_ref 12.4p3.
33
34__header ` #include <boost/type_traits/has_trivial_destructor.hpp>` or ` #include <boost/type_traits.hpp>`
35
36__examples
37
38[:`has_trivial_destructor<int>` inherits from `__true_type`.]
39
40[:`has_trivial_destructor<char*>::type` is the type `__true_type`.]
41
42[:`has_trivial_destructor<int (*)(long)>::value` is an integral constant
43expression that evaluates to /true/.]
44
45[:`has_trivial_destructor<MyClass>::value` is an integral constant
46expression that evaluates to /false/.]
47
48[:`has_trivial_destructor<T>::value_type` is the type `bool`.]
49
50[endsect]
51