Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: // Chris@101: // (C) Copyright Ion Gaztanaga 2005-2013. Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/container for documentation. Chris@16: // Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: Chris@16: #ifndef BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP Chris@16: #define BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP Chris@16: Chris@101: #ifndef BOOST_CONFIG_HPP Chris@101: # include Chris@101: #endif Chris@101: Chris@101: #if defined(BOOST_HAS_PRAGMA_ONCE) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@101: #include Chris@101: #include Chris@101: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace container { Chris@16: namespace container_detail { Chris@16: Chris@16: template Chris@16: struct integral_constant Chris@16: { Chris@16: static const T value = val; Chris@16: typedef integral_constant type; Chris@16: }; Chris@16: Chris@16: template< bool C_ > Chris@16: struct bool_ : integral_constant Chris@16: { Chris@16: static const bool value = C_; Chris@16: operator bool() const { return bool_::value; } Chris@16: }; Chris@16: Chris@101: template< unsigned V_ > Chris@101: struct unsigned_ : integral_constant Chris@101: { Chris@101: static const unsigned value = V_; Chris@101: operator unsigned() const { return unsigned_::value; } Chris@101: }; Chris@101: Chris@16: typedef bool_ true_; Chris@16: typedef bool_ false_; Chris@16: Chris@16: typedef true_ true_type; Chris@16: typedef false_ false_type; Chris@16: Chris@16: typedef char yes_type; Chris@16: struct no_type Chris@16: { Chris@16: char padding[8]; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct enable_if_c { Chris@16: typedef T type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct enable_if_c {}; Chris@16: Chris@16: template Chris@16: struct enable_if : public enable_if_c {}; Chris@16: Chris@16: template Chris@16: struct disable_if : public enable_if_c {}; Chris@16: Chris@16: template Chris@16: struct disable_if_c : public enable_if_c {}; Chris@16: Chris@101: #if defined(_MSC_VER) && (_MSC_VER >= 1400) Chris@101: Chris@101: template Chris@101: struct is_convertible Chris@101: { Chris@101: static const bool value = __is_convertible_to(T, U); Chris@101: }; Chris@101: Chris@101: #else Chris@101: Chris@16: template Chris@16: class is_convertible Chris@16: { Chris@16: typedef char true_t; Chris@16: class false_t { char dummy[2]; }; Chris@101: //use any_conversion as first parameter since in MSVC Chris@101: //overaligned types can't go through ellipsis Chris@16: static false_t dispatch(...); Chris@101: static true_t dispatch(U); Chris@101: static T &trigger(); Chris@16: public: Chris@101: static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t); Chris@16: }; Chris@16: Chris@101: #endif Chris@101: Chris@16: template< Chris@16: bool C Chris@16: , typename T1 Chris@16: , typename T2 Chris@16: > Chris@16: struct if_c Chris@16: { Chris@16: typedef T1 type; Chris@16: }; Chris@16: Chris@16: template< Chris@16: typename T1 Chris@16: , typename T2 Chris@16: > Chris@16: struct if_c Chris@16: { Chris@16: typedef T2 type; Chris@16: }; Chris@16: Chris@16: template< Chris@16: typename T1 Chris@16: , typename T2 Chris@16: , typename T3 Chris@16: > Chris@16: struct if_ Chris@16: { Chris@16: typedef typename if_c<0 != T1::value, T2, T3>::type type; Chris@16: }; Chris@16: Chris@16: Chris@16: template Chris@16: struct select1st Chris@16: { Chris@101: typedef Pair argument_type; Chris@101: typedef typename Pair::first_type result_type; Chris@101: Chris@16: template Chris@16: const typename Pair::first_type& operator()(const OtherPair& x) const Chris@16: { return x.first; } Chris@16: Chris@16: const typename Pair::first_type& operator()(const typename Pair::first_type& x) const Chris@16: { return x; } Chris@16: }; Chris@16: Chris@16: // identity is an extension: it is not part of the standard. Chris@16: template Chris@16: struct identity Chris@16: { Chris@101: typedef T argument_type; Chris@101: typedef T result_type; Chris@101: Chris@16: typedef T type; Chris@16: const T& operator()(const T& x) const Chris@16: { return x; } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct ls_zeros Chris@16: { Chris@16: static const std::size_t value = (S & std::size_t(1)) ? 0 : (1u + ls_zeros<(S >> 1u)>::value); Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct ls_zeros<0> Chris@16: { Chris@16: static const std::size_t value = 0; Chris@16: }; Chris@16: Chris@16: template<> Chris@16: struct ls_zeros<1> Chris@16: { Chris@16: static const std::size_t value = 0; Chris@16: }; Chris@16: Chris@101: template Chris@101: struct ct_rounded_size Chris@101: { Chris@101: static const std::size_t value = ((OrigSize-1)/RoundTo+1)*RoundTo; Chris@101: }; Chris@101: Chris@16: template struct unvoid { typedef T type; }; Chris@16: template <> struct unvoid { struct type { }; }; Chris@16: template <> struct unvoid { struct type { }; }; Chris@16: Chris@16: } //namespace container_detail { Chris@16: } //namespace container { Chris@16: } //namespace boost { Chris@16: Chris@101: #include Chris@101: Chris@16: #endif //#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP Chris@16: