Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: // Chris@16: // (C) Copyright Ion Gaztanaga 2005-2012. 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/interprocess for documentation. Chris@16: // Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: Chris@16: #ifndef BOOST_INTERPROCESS_DETAIL_MPL_HPP Chris@16: #define BOOST_INTERPROCESS_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@16: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace interprocess { Chris@16: namespace ipcdetail { 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: }; 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 disable_if : public enable_if_c {}; 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 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 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: // : public std::unary_function Chris@16: { 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: // : public std::unary_function Chris@16: { 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@16: } //namespace ipcdetail { Chris@16: } //namespace interprocess { Chris@16: } //namespace boost { Chris@16: Chris@16: #endif //#ifndef BOOST_INTERPROCESS_DETAIL_MPL_HPP Chris@16: