Chris@16: ///////////////////////////////////////////////////////////////////////////// Chris@16: // Chris@16: // (C) Copyright Ion Gaztanaga 2006-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/intrusive for documentation. Chris@16: // Chris@16: ///////////////////////////////////////////////////////////////////////////// Chris@16: Chris@16: #ifndef BOOST_INTRUSIVE_DETAIL_MPL_HPP Chris@16: #define BOOST_INTRUSIVE_DETAIL_MPL_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace intrusive { Chris@16: namespace detail { Chris@16: Chris@16: typedef char one; Chris@16: struct two {one _[2];}; Chris@16: Chris@16: template< bool C_ > Chris@16: struct bool_ Chris@16: { Chris@16: static const bool value = C_; Chris@16: }; Chris@16: 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 apply Chris@16: { Chris@16: typedef typename F::template apply::type type; Chris@16: }; Chris@16: 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@16: static true_t dispatch(U); Chris@16: static false_t dispatch(...); Chris@16: static const T &trigger(); Chris@16: public: Chris@16: static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t); Chris@16: }; Chris@16: 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 C Chris@16: , typename T1 Chris@16: , typename T2 Chris@16: > Chris@16: struct if_ Chris@16: { Chris@16: typedef typename if_c<0 != C::value, T1, T2>::type type; Chris@16: }; Chris@16: Chris@16: template< Chris@16: bool C Chris@16: , typename F1 Chris@16: , typename F2 Chris@16: > Chris@16: struct eval_if_c Chris@16: : if_c::type Chris@16: {}; Chris@16: Chris@16: template< Chris@16: typename C Chris@16: , typename T1 Chris@16: , typename T2 Chris@16: > Chris@16: struct eval_if Chris@16: : if_::type 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@16: typedef T type; Chris@16: }; Chris@16: Chris@16: #if defined(BOOST_MSVC) || defined(__BORLANDC_) Chris@16: #define BOOST_INTRUSIVE_TT_DECL __cdecl Chris@16: #else Chris@16: #define BOOST_INTRUSIVE_TT_DECL Chris@16: #endif Chris@16: Chris@16: #if defined(_MSC_EXTENSIONS) && !defined(__BORLAND__) && !defined(_WIN64) && !defined(UNDER_CE) Chris@16: #define BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS Chris@16: #endif Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = false; }; Chris@16: Chris@16: // see boost ticket #4094 Chris@16: // avoid duplicate definitions of is_unary_or_binary_function_impl Chris@16: #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: #else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: #ifndef _MANAGED Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: #endif Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: #endif Chris@16: Chris@16: // see boost ticket #4094 Chris@16: // avoid duplicate definitions of is_unary_or_binary_function_impl Chris@16: #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: #else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: #ifndef _MANAGED Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: #endif Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: #endif Chris@16: Chris@16: // see boost ticket #4094 Chris@16: // avoid duplicate definitions of is_unary_or_binary_function_impl Chris@16: #ifndef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: #else // BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: #ifndef _MANAGED Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: #endif Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = true; }; Chris@16: #endif Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function_impl Chris@16: { static const bool value = false; }; Chris@16: Chris@16: template Chris@16: struct is_unary_or_binary_function Chris@16: { static const bool value = is_unary_or_binary_function_impl::value; }; Chris@16: Chris@16: //boost::alignment_of yields to 10K lines of preprocessed code, so we Chris@16: //need an alternative Chris@16: template struct alignment_of; Chris@16: Chris@16: template Chris@16: struct alignment_of_hack Chris@16: { Chris@16: char c; Chris@16: T t; Chris@16: alignment_of_hack(); Chris@16: }; Chris@16: Chris@16: template Chris@16: struct alignment_logic Chris@16: { Chris@16: static const std::size_t value = A < S ? A : S; Chris@16: }; Chris@16: Chris@16: template< typename T > Chris@16: struct alignment_of Chris@16: { Chris@16: static const std::size_t value = alignment_logic Chris@16: < sizeof(alignment_of_hack) - sizeof(T) Chris@16: , sizeof(T) Chris@16: >::value; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct is_same Chris@16: { Chris@16: static const bool value = false; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct is_same Chris@16: { Chris@16: static const bool value = true; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct add_const Chris@16: { typedef const T type; }; Chris@16: Chris@16: template Chris@16: struct remove_const Chris@16: { typedef T type; }; Chris@16: Chris@16: template Chris@16: struct remove_const Chris@16: { typedef T type; }; Chris@16: Chris@16: template Chris@16: struct remove_cv Chris@16: { typedef T type; }; Chris@16: Chris@16: template Chris@16: struct remove_cv Chris@16: { typedef T type; }; Chris@16: Chris@16: template Chris@16: struct remove_cv Chris@16: { typedef T type; }; Chris@16: Chris@16: template Chris@16: struct remove_cv Chris@16: { typedef T type; }; Chris@16: Chris@16: template Chris@16: struct remove_reference Chris@16: { Chris@16: typedef T type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct remove_reference Chris@16: { Chris@16: typedef T type; Chris@16: }; Chris@16: Chris@16: template Chris@16: class is_empty_class Chris@16: { Chris@16: template Chris@16: struct empty_helper_t1 : public T Chris@16: { Chris@16: empty_helper_t1(); Chris@16: int i[256]; Chris@16: }; Chris@16: Chris@16: struct empty_helper_t2 Chris@16: { int i[256]; }; Chris@16: Chris@16: public: Chris@16: static const bool value = sizeof(empty_helper_t1) == sizeof(empty_helper_t2); 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 : (1 + 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@16: } //namespace detail Chris@16: } //namespace intrusive Chris@16: } //namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif //BOOST_INTRUSIVE_DETAIL_MPL_HPP