annotate DEPENDENCIES/generic/include/boost/container/detail/mpl.hpp @ 16:2665513ce2d3

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