////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2012-2012. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/move for documentation. // ////////////////////////////////////////////////////////////////////////////// //! \file #ifndef BOOST_MOVE_DETAIL_META_UTILS_HPP #define BOOST_MOVE_DETAIL_META_UTILS_HPP #include //Small meta-typetraits to support move namespace boost { namespace move_detail { //if_ template struct if_c { typedef T1 type; }; template struct if_c { typedef T2 type; }; template struct if_ { typedef typename if_c<0 != T1::value, T2, T3>::type type; }; //enable_if_ template struct enable_if_c { typedef T type; }; template struct enable_if_c {}; template struct enable_if : public enable_if_c {}; template struct disable_if : public enable_if_c {}; //integral_constant template struct integral_constant { static const T value = v; typedef T value_type; typedef integral_constant type; }; //identity template struct identity { typedef T type; }; #if defined(_MSC_VER) && (_MSC_VER >= 1400) //use intrinsic since in MSVC //overaligned types can't go through ellipsis template struct is_convertible { static const bool value = __is_convertible_to(T, U); }; #else template class is_convertible { typedef char true_t; class false_t { char dummy[2]; }; static false_t dispatch(...); static true_t dispatch(U); static T &trigger(); public: static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t); }; #endif //and_ not_ template > struct and_ : public integral_constant {}; template struct not_ : public integral_constant {}; //is_lvalue_reference template struct is_lvalue_reference : public integral_constant {}; template struct is_lvalue_reference : public integral_constant {}; template struct is_class_or_union { struct twochar { char _[2]; }; template static char is_class_or_union_tester(void(U::*)(void)); template static twochar is_class_or_union_tester(...); static const bool value = sizeof(is_class_or_union_tester(0)) == sizeof(char); }; struct empty{}; //addressof template struct addr_impl_ref { T & v_; inline addr_impl_ref( T & v ): v_( v ) {} inline operator T& () const { return v_; } private: addr_impl_ref & operator=(const addr_impl_ref &); }; template struct addressof_impl { static inline T * f( T & v, long ) { return reinterpret_cast( &const_cast(reinterpret_cast(v))); } static inline T * f( T * v, int ) { return v; } }; template inline T * addressof( T & v ) { return ::boost::move_detail::addressof_impl::f ( ::boost::move_detail::addr_impl_ref( v ), 0 ); } } //namespace move_detail { } //namespace boost { #include #endif //#ifndef BOOST_MOVE_DETAIL_META_UTILS_HPP