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