blob: 084374b94a1145305e546128ad22ee52608f781c [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_copy has_trivial_copy]
9
10 template <class T>
11 struct has_trivial_copy : public __tof {};
12
13 template <class T>
14 struct has_trivial_copy_constructor : public __tof {};
15
16__inherit If T is a (possibly cv-qualified) type with a trivial copy-constructor
17then inherits from __true_type, otherwise inherits from __false_type.
18
19These two traits are synonyms for each other.
20
21If a type has a trivial copy-constructor then the constructor has the same effect
22as copying the bits of one object to the other:
23calls to the constructor can be safely replaced with a call to `memcpy`.
24
25__compat Without some (as yet unspecified) help from the compiler,
26has_trivial_copy will never report that a user-defined class or struct has a
27trivial constructor; this is always safe, if possibly sub-optimal.
28In addition, in order to correctly handle deleted or private copy-constructors
29then C++11's `dectype` is required.
30Currently (May 2015) compilers more recent than Visual C++ 8, GCC-4.3, Greenhills 6.0,
31Intel-11.0, and Codegear have the necessary compiler __intrinsics to ensure that this
32trait "just works". You may also test to see if the necessary __intrinsics are available
33by checking to see if the macro `BOOST_HAS_TRIVIAL_COPY` is defined.
34
35
36__std_ref 12.8p6.
37
38__header ` #include <boost/type_traits/has_trivial_copy.hpp>` or ` #include <boost/type_traits.hpp>`
39
40__examples
41
42[:`has_trivial_copy<int>` inherits from `__true_type`.]
43
44[:`has_trivial_copy<char*>::type` is the type `__true_type`.]
45
46[:`has_trivial_copy<int (*)(long)>::value` is an integral constant
47expression that evaluates to /true/.]
48
49[:`has_trivial_copy<MyClass>::value` is an integral constant
50expression that evaluates to /false/.]
51
52[:`has_trivial_copy<T>::value_type` is the type `bool`.]
53
54[endsect]
55