annotate DEPENDENCIES/generic/include/boost/container/detail/mpl.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //////////////////////////////////////////////////////////////////////////////
Chris@16 2 //
Chris@101 3 // (C) Copyright Ion Gaztanaga 2005-2013.
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@101 16 #ifndef BOOST_CONFIG_HPP
Chris@101 17 # include <boost/config.hpp>
Chris@101 18 #endif
Chris@101 19
Chris@101 20 #if defined(BOOST_HAS_PRAGMA_ONCE)
Chris@16 21 # pragma once
Chris@16 22 #endif
Chris@16 23
Chris@101 24 #include <boost/container/detail/config_begin.hpp>
Chris@101 25 #include <boost/container/detail/workaround.hpp>
Chris@101 26
Chris@16 27 #include <cstddef>
Chris@16 28
Chris@16 29 namespace boost {
Chris@16 30 namespace container {
Chris@16 31 namespace container_detail {
Chris@16 32
Chris@16 33 template <class T, T val>
Chris@16 34 struct integral_constant
Chris@16 35 {
Chris@16 36 static const T value = val;
Chris@16 37 typedef integral_constant<T,val> type;
Chris@16 38 };
Chris@16 39
Chris@16 40 template< bool C_ >
Chris@16 41 struct bool_ : integral_constant<bool, C_>
Chris@16 42 {
Chris@16 43 static const bool value = C_;
Chris@16 44 operator bool() const { return bool_::value; }
Chris@16 45 };
Chris@16 46
Chris@101 47 template< unsigned V_ >
Chris@101 48 struct unsigned_ : integral_constant<unsigned, V_>
Chris@101 49 {
Chris@101 50 static const unsigned value = V_;
Chris@101 51 operator unsigned() const { return unsigned_::value; }
Chris@101 52 };
Chris@101 53
Chris@16 54 typedef bool_<true> true_;
Chris@16 55 typedef bool_<false> false_;
Chris@16 56
Chris@16 57 typedef true_ true_type;
Chris@16 58 typedef false_ false_type;
Chris@16 59
Chris@16 60 typedef char yes_type;
Chris@16 61 struct no_type
Chris@16 62 {
Chris@16 63 char padding[8];
Chris@16 64 };
Chris@16 65
Chris@16 66 template <bool B, class T = void>
Chris@16 67 struct enable_if_c {
Chris@16 68 typedef T type;
Chris@16 69 };
Chris@16 70
Chris@16 71 template <class T>
Chris@16 72 struct enable_if_c<false, T> {};
Chris@16 73
Chris@16 74 template <class Cond, class T = void>
Chris@16 75 struct enable_if : public enable_if_c<Cond::value, T> {};
Chris@16 76
Chris@16 77 template <class Cond, class T = void>
Chris@16 78 struct disable_if : public enable_if_c<!Cond::value, T> {};
Chris@16 79
Chris@16 80 template <bool B, class T = void>
Chris@16 81 struct disable_if_c : public enable_if_c<!B, T> {};
Chris@16 82
Chris@101 83 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
Chris@101 84
Chris@101 85 template <class T, class U>
Chris@101 86 struct is_convertible
Chris@101 87 {
Chris@101 88 static const bool value = __is_convertible_to(T, U);
Chris@101 89 };
Chris@101 90
Chris@101 91 #else
Chris@101 92
Chris@16 93 template <class T, class U>
Chris@16 94 class is_convertible
Chris@16 95 {
Chris@16 96 typedef char true_t;
Chris@16 97 class false_t { char dummy[2]; };
Chris@101 98 //use any_conversion as first parameter since in MSVC
Chris@101 99 //overaligned types can't go through ellipsis
Chris@16 100 static false_t dispatch(...);
Chris@101 101 static true_t dispatch(U);
Chris@101 102 static T &trigger();
Chris@16 103 public:
Chris@101 104 static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t);
Chris@16 105 };
Chris@16 106
Chris@101 107 #endif
Chris@101 108
Chris@16 109 template<
Chris@16 110 bool C
Chris@16 111 , typename T1
Chris@16 112 , typename T2
Chris@16 113 >
Chris@16 114 struct if_c
Chris@16 115 {
Chris@16 116 typedef T1 type;
Chris@16 117 };
Chris@16 118
Chris@16 119 template<
Chris@16 120 typename T1
Chris@16 121 , typename T2
Chris@16 122 >
Chris@16 123 struct if_c<false,T1,T2>
Chris@16 124 {
Chris@16 125 typedef T2 type;
Chris@16 126 };
Chris@16 127
Chris@16 128 template<
Chris@16 129 typename T1
Chris@16 130 , typename T2
Chris@16 131 , typename T3
Chris@16 132 >
Chris@16 133 struct if_
Chris@16 134 {
Chris@16 135 typedef typename if_c<0 != T1::value, T2, T3>::type type;
Chris@16 136 };
Chris@16 137
Chris@16 138
Chris@16 139 template <class Pair>
Chris@16 140 struct select1st
Chris@16 141 {
Chris@101 142 typedef Pair argument_type;
Chris@101 143 typedef typename Pair::first_type result_type;
Chris@101 144
Chris@16 145 template<class OtherPair>
Chris@16 146 const typename Pair::first_type& operator()(const OtherPair& x) const
Chris@16 147 { return x.first; }
Chris@16 148
Chris@16 149 const typename Pair::first_type& operator()(const typename Pair::first_type& x) const
Chris@16 150 { return x; }
Chris@16 151 };
Chris@16 152
Chris@16 153 // identity is an extension: it is not part of the standard.
Chris@16 154 template <class T>
Chris@16 155 struct identity
Chris@16 156 {
Chris@101 157 typedef T argument_type;
Chris@101 158 typedef T result_type;
Chris@101 159
Chris@16 160 typedef T type;
Chris@16 161 const T& operator()(const T& x) const
Chris@16 162 { return x; }
Chris@16 163 };
Chris@16 164
Chris@16 165 template<std::size_t S>
Chris@16 166 struct ls_zeros
Chris@16 167 {
Chris@16 168 static const std::size_t value = (S & std::size_t(1)) ? 0 : (1u + ls_zeros<(S >> 1u)>::value);
Chris@16 169 };
Chris@16 170
Chris@16 171 template<>
Chris@16 172 struct ls_zeros<0>
Chris@16 173 {
Chris@16 174 static const std::size_t value = 0;
Chris@16 175 };
Chris@16 176
Chris@16 177 template<>
Chris@16 178 struct ls_zeros<1>
Chris@16 179 {
Chris@16 180 static const std::size_t value = 0;
Chris@16 181 };
Chris@16 182
Chris@101 183 template <std::size_t OrigSize, std::size_t RoundTo>
Chris@101 184 struct ct_rounded_size
Chris@101 185 {
Chris@101 186 static const std::size_t value = ((OrigSize-1)/RoundTo+1)*RoundTo;
Chris@101 187 };
Chris@101 188
Chris@16 189 template <typename T> struct unvoid { typedef T type; };
Chris@16 190 template <> struct unvoid<void> { struct type { }; };
Chris@16 191 template <> struct unvoid<const void> { struct type { }; };
Chris@16 192
Chris@16 193 } //namespace container_detail {
Chris@16 194 } //namespace container {
Chris@16 195 } //namespace boost {
Chris@16 196
Chris@101 197 #include <boost/container/detail/config_end.hpp>
Chris@101 198
Chris@16 199 #endif //#ifndef BOOST_CONTAINER_CONTAINER_DETAIL_MPL_HPP
Chris@16 200