Brian Silverman | 4a2409e | 2018-08-04 23:24:02 -0700 | [diff] [blame^] | 1 | [/ |
| 2 | Copyright 2007 John Maddock. |
| 3 | Copyright 2013 Antony Polukhin. |
| 4 | Distributed under the Boost Software License, Version 1.0. |
| 5 | (See accompanying file LICENSE_1_0.txt or copy at |
| 6 | http://www.boost.org/LICENSE_1_0.txt). |
| 7 | ] |
| 8 | |
| 9 | [section:has_trivial_move_constructor has_trivial_move_constructor] |
| 10 | |
| 11 | template <class T> |
| 12 | struct has_trivial_move_constructor : public __tof {}; |
| 13 | |
| 14 | __inherit If T is a (possibly cv-qualified) type with a trivial move-constructor |
| 15 | then inherits from __true_type, otherwise inherits from __false_type. |
| 16 | |
| 17 | If a type has a trivial move-constructor then the constructor has the same effect |
| 18 | as copying the bits of one object to the other: |
| 19 | calls to the constructor can be safely replaced with a call to `memcpy`. |
| 20 | |
| 21 | __compat Without some (as yet unspecified) help from the compiler, |
| 22 | has_trivial_move_constructor will never report that a user-defined class or struct has a |
| 23 | trivial constructor; this is always safe, if possibly sub-optimal. |
| 24 | In addition C++11's `decltype` is required to correctly support deleted or private |
| 25 | move constructors. |
| 26 | Currently (June 2015) compilers that have the necessary __intrinsics to ensure that this |
| 27 | trait "just works" include Clang, GCC-5.1, and MSVC-12.0. |
| 28 | You may also test to see if the necessary __intrinsics are available |
| 29 | by checking to see if the macro `BOOST_HAS_TRIVIAL_MOVE_CONSTRUCTOR` is defined. |
| 30 | |
| 31 | |
| 32 | __header ` #include <boost/type_traits/has_trivial_move_constructor.hpp>` or ` #include <boost/type_traits.hpp>` |
| 33 | |
| 34 | __examples |
| 35 | |
| 36 | [:`has_trivial_move_constructor<int>` inherits from `__true_type`.] |
| 37 | |
| 38 | [:`has_trivial_move_constructor<char*>::type` is the type `__true_type`.] |
| 39 | |
| 40 | [:`has_trivial_move_constructor<int (*)(long)>::value` is an integral constant |
| 41 | expression that evaluates to /true/.] |
| 42 | |
| 43 | [:`has_trivial_move_constructor<MyClass>::value` is an integral constant |
| 44 | expression that evaluates to /false/.] |
| 45 | |
| 46 | [:`has_trivial_move_constructor<T>::value_type` is the type `bool`.] |
| 47 | |
| 48 | [endsect] |
| 49 | |