PageRenderTime 25ms CodeModel.GetById 16ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/interprocess/detail/mpl.hpp

http://hadesmem.googlecode.com/
C++ Header | 152 lines | 111 code | 27 blank | 14 comment | 3 complexity | 6d533dc4d6f17c7b6cbf00d9d55e516b MD5 | raw file
  1//////////////////////////////////////////////////////////////////////////////
  2//
  3// (C) Copyright Ion Gaztanaga 2005-2009.
  4//
  5// Distributed under the Boost Software License, Version 1.0.
  6// (See accompanying file LICENSE_1_0.txt or copy at
  7// http://www.boost.org/LICENSE_1_0.txt)
  8//
  9// See http://www.boost.org/libs/interprocess for documentation.
 10//
 11//////////////////////////////////////////////////////////////////////////////
 12
 13#ifndef BOOST_INTERPROCESS_DETAIL_MPL_HPP
 14#define BOOST_INTERPROCESS_DETAIL_MPL_HPP
 15
 16#if (defined _MSC_VER) && (_MSC_VER >= 1200)
 17#  pragma once
 18#endif
 19
 20#include <cstddef>
 21
 22namespace boost {
 23namespace interprocess { 
 24namespace detail {
 25
 26template <class T, T val>
 27struct integral_constant
 28{
 29   static const T value = val;
 30   typedef integral_constant<T,val> type;
 31};
 32
 33template< bool C_ >
 34struct bool_ : integral_constant<bool, C_>
 35{
 36   static const bool value = C_;
 37};
 38
 39typedef bool_<true>        true_;
 40typedef bool_<false>       false_;
 41
 42typedef true_  true_type;
 43typedef false_ false_type;
 44
 45typedef char yes_type;
 46struct no_type
 47{
 48   char padding[8];
 49};
 50
 51template <bool B, class T = void>
 52struct enable_if_c {
 53  typedef T type;
 54};
 55
 56template <class T>
 57struct enable_if_c<false, T> {};
 58
 59template <class Cond, class T = void>
 60struct enable_if : public enable_if_c<Cond::value, T> {};
 61
 62template <class Cond, class T = void>
 63struct disable_if : public enable_if_c<!Cond::value, T> {};
 64
 65template <class T, class U>
 66class is_convertible
 67{
 68   typedef char true_t;
 69   class false_t { char dummy[2]; };
 70   static true_t dispatch(U);
 71   static false_t dispatch(...);
 72   static T trigger();
 73   public:
 74   enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) };
 75};
 76
 77template<
 78      bool C
 79    , typename T1
 80    , typename T2
 81    >
 82struct if_c
 83{
 84    typedef T1 type;
 85};
 86
 87template<
 88      typename T1
 89    , typename T2
 90    >
 91struct if_c<false,T1,T2>
 92{
 93    typedef T2 type;
 94};
 95
 96template<
 97      typename T1
 98    , typename T2
 99    , typename T3
100    >
101struct if_
102{
103   typedef typename if_c<0 != T1::value, T2, T3>::type type;
104};
105
106
107template <class Pair>
108struct select1st 
109//   : public std::unary_function<Pair, typename Pair::first_type> 
110{
111   template<class OtherPair>
112   const typename Pair::first_type& operator()(const OtherPair& x) const 
113   {  return x.first;   }
114
115   const typename Pair::first_type& operator()(const typename Pair::first_type& x) const 
116   {  return x;   }
117};
118
119// identity is an extension: it is not part of the standard.
120template <class T>
121struct identity 
122//   : public std::unary_function<T,T> 
123{
124   typedef T type;
125   const T& operator()(const T& x) const 
126   { return x; }
127};
128
129template<std::size_t S>
130struct ls_zeros
131{
132   static const std::size_t value = (S & std::size_t(1)) ? 0 : (1u + ls_zeros<(S >> 1u)>::value);
133};
134
135template<>
136struct ls_zeros<0>
137{
138   static const std::size_t value = 0;
139};
140
141template<>
142struct ls_zeros<1>
143{
144   static const std::size_t value = 0;
145};
146
147}  //namespace detail { 
148}  //namespace interprocess { 
149}  //namespace boost {
150
151#endif   //#ifndef BOOST_INTERPROCESS_DETAIL_MPL_HPP
152