Chris@16
|
1 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 //
|
Chris@16
|
3 // (C) Copyright Ion Gaztanaga 2009-2012.
|
Chris@16
|
4 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
5 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 //
|
Chris@16
|
8 // See http://www.boost.org/libs/move for documentation.
|
Chris@16
|
9 //
|
Chris@16
|
10 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
11
|
Chris@16
|
12 //! \file
|
Chris@16
|
13
|
Chris@101
|
14 #ifndef BOOST_MOVE_TRAITS_HPP
|
Chris@101
|
15 #define BOOST_MOVE_TRAITS_HPP
|
Chris@101
|
16
|
Chris@101
|
17 #ifndef BOOST_CONFIG_HPP
|
Chris@101
|
18 # include <boost/config.hpp>
|
Chris@101
|
19 #endif
|
Chris@101
|
20 #
|
Chris@101
|
21 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@101
|
22 # pragma once
|
Chris@101
|
23 #endif
|
Chris@16
|
24
|
Chris@16
|
25 #include <boost/move/detail/config_begin.hpp>
|
Chris@16
|
26
|
Chris@16
|
27 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
Chris@16
|
28 #include <boost/move/core.hpp>
|
Chris@16
|
29 #endif
|
Chris@101
|
30 #include <boost/move/detail/meta_utils.hpp>
|
Chris@101
|
31 #include <boost/move/detail/type_traits.hpp>
|
Chris@16
|
32
|
Chris@16
|
33 namespace boost {
|
Chris@16
|
34
|
Chris@16
|
35 //! If this trait yields to true
|
Chris@16
|
36 //! (<i>has_trivial_destructor_after_move <T>::value == true</i>)
|
Chris@16
|
37 //! means that if T is used as argument of a move construction/assignment,
|
Chris@16
|
38 //! there is no need to call T's destructor.
|
Chris@16
|
39 //! This optimization tipically is used to improve containers' performance.
|
Chris@16
|
40 //!
|
Chris@16
|
41 //! By default this trait is true if the type has trivial destructor,
|
Chris@16
|
42 //! every class should specialize this trait if it wants to improve performance
|
Chris@16
|
43 //! when inserted in containers.
|
Chris@16
|
44 template <class T>
|
Chris@16
|
45 struct has_trivial_destructor_after_move
|
Chris@101
|
46 : ::boost::move_detail::is_trivially_destructible<T>
|
Chris@16
|
47 {};
|
Chris@16
|
48
|
Chris@16
|
49 //! By default this traits returns
|
Chris@16
|
50 //! <pre>boost::is_nothrow_move_constructible<T>::value && boost::is_nothrow_move_assignable<T>::value </pre>.
|
Chris@16
|
51 //! Classes with non-throwing move constructor
|
Chris@16
|
52 //! and assignment can specialize this trait to obtain some performance improvements.
|
Chris@16
|
53 template <class T>
|
Chris@16
|
54 struct has_nothrow_move
|
Chris@101
|
55 {
|
Chris@101
|
56 static const bool value = boost::move_detail::is_nothrow_move_constructible<T>::value &&
|
Chris@101
|
57 boost::move_detail::is_nothrow_move_assignable<T>::value;
|
Chris@101
|
58 };
|
Chris@16
|
59
|
Chris@16
|
60 namespace move_detail {
|
Chris@16
|
61
|
Chris@101
|
62 template <class T>
|
Chris@101
|
63 struct is_nothrow_move_constructible_or_uncopyable
|
Chris@101
|
64 {
|
Chris@101
|
65 //The standard requires is_nothrow_move_constructible for move_if_noexcept
|
Chris@101
|
66 //but a user (usually in C++03) might specialize has_nothrow_move which includes it
|
Chris@101
|
67 static const bool value = is_nothrow_move_constructible<T>::value ||
|
Chris@101
|
68 has_nothrow_move<T>::value ||
|
Chris@101
|
69 !is_copy_constructible<T>::value;
|
Chris@101
|
70 };
|
Chris@16
|
71
|
Chris@16
|
72 } //move_detail {
|
Chris@16
|
73 } //namespace boost {
|
Chris@16
|
74
|
Chris@16
|
75 #include <boost/move/detail/config_end.hpp>
|
Chris@16
|
76
|
Chris@101
|
77 #endif //#ifndef BOOST_MOVE_TRAITS_HPP
|