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