diff options
Diffstat (limited to 'boost/container/detail/mpl.hpp')
-rw-r--r-- | boost/container/detail/mpl.hpp | 175 |
1 files changed, 31 insertions, 144 deletions
diff --git a/boost/container/detail/mpl.hpp b/boost/container/detail/mpl.hpp index 74b618f8c6..e1684ea0b1 100644 --- a/boost/container/detail/mpl.hpp +++ b/boost/container/detail/mpl.hpp @@ -23,6 +23,8 @@ #include <boost/container/detail/config_begin.hpp> #include <boost/container/detail/workaround.hpp> +#include <boost/move/detail/type_traits.hpp> +#include <boost/intrusive/detail/mpl.hpp> #include <cstddef> @@ -30,110 +32,35 @@ namespace boost { namespace container { namespace container_detail { -template <class T, T val> -struct integral_constant -{ - static const T value = val; - typedef integral_constant<T,val> type; -}; - -template< bool C_ > -struct bool_ : integral_constant<bool, C_> -{ - static const bool value = C_; - operator bool() const { return bool_::value; } -}; - -template< unsigned V_ > -struct unsigned_ : integral_constant<unsigned, V_> -{ - static const unsigned value = V_; - operator unsigned() const { return unsigned_::value; } -}; - -typedef bool_<true> true_; -typedef bool_<false> false_; - -typedef true_ true_type; -typedef false_ false_type; - -typedef char yes_type; -struct no_type -{ - char padding[8]; -}; - -template <bool B, class T = void> -struct enable_if_c { - typedef T type; -}; - -template <class T> -struct enable_if_c<false, T> {}; - -template <class Cond, class T = void> -struct enable_if : public enable_if_c<Cond::value, T> {}; - -template <class Cond, class T = void> -struct disable_if : public enable_if_c<!Cond::value, T> {}; - -template <bool B, class T = void> -struct disable_if_c : public enable_if_c<!B, T> {}; - -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - -template <class T, class U> -struct is_convertible -{ - static const bool value = __is_convertible_to(T, U); -}; - -#else - -template <class T, class U> -class is_convertible -{ - typedef char true_t; - class false_t { char dummy[2]; }; - //use any_conversion as first parameter since in MSVC - //overaligned types can't go through ellipsis - static false_t dispatch(...); - static true_t dispatch(U); - static T &trigger(); - public: - static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t); -}; - -#endif - -template< - bool C - , typename T1 - , typename T2 - > -struct if_c -{ - typedef T1 type; -}; - -template< - typename T1 - , typename T2 - > -struct if_c<false,T1,T2> -{ - typedef T2 type; -}; - -template< - typename T1 - , typename T2 - , typename T3 - > -struct if_ -{ - typedef typename if_c<0 != T1::value, T2, T3>::type type; -}; +using boost::move_detail::integral_constant; +using boost::move_detail::true_type; +using boost::move_detail::false_type; +using boost::move_detail::enable_if_c; +using boost::move_detail::enable_if; +using boost::move_detail::enable_if_convertible; +using boost::move_detail::disable_if_c; +using boost::move_detail::disable_if; +using boost::move_detail::disable_if_convertible; +using boost::move_detail::is_convertible; +using boost::move_detail::if_c; +using boost::move_detail::if_; +using boost::move_detail::identity; +using boost::move_detail::bool_; +using boost::move_detail::true_; +using boost::move_detail::false_; +using boost::move_detail::yes_type; +using boost::move_detail::no_type; +using boost::move_detail::bool_; +using boost::move_detail::true_; +using boost::move_detail::false_; +using boost::move_detail::unvoid_ref; +using boost::move_detail::and_; +using boost::move_detail::or_; +using boost::move_detail::not_; +using boost::move_detail::enable_if_and; +using boost::move_detail::disable_if_and; +using boost::move_detail::enable_if_or; +using boost::move_detail::disable_if_or; template <class Pair> @@ -150,46 +77,6 @@ struct select1st { return x; } }; -// identity is an extension: it is not part of the standard. -template <class T> -struct identity -{ - typedef T argument_type; - typedef T result_type; - - typedef T type; - const T& operator()(const T& x) const - { return x; } -}; - -template<std::size_t S> -struct ls_zeros -{ - static const std::size_t value = (S & std::size_t(1)) ? 0 : (1u + ls_zeros<(S >> 1u)>::value); -}; - -template<> -struct ls_zeros<0> -{ - static const std::size_t value = 0; -}; - -template<> -struct ls_zeros<1> -{ - static const std::size_t value = 0; -}; - -template <std::size_t OrigSize, std::size_t RoundTo> -struct ct_rounded_size -{ - static const std::size_t value = ((OrigSize-1)/RoundTo+1)*RoundTo; -}; - -template <typename T> struct unvoid { typedef T type; }; -template <> struct unvoid<void> { struct type { }; }; -template <> struct unvoid<const void> { struct type { }; }; - } //namespace container_detail { } //namespace container { } //namespace boost { |