Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/interprocess/detail/mpl.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 ////////////////////////////////////////////////////////////////////////////// | |
2 // | |
3 // (C) Copyright Ion Gaztanaga 2005-2012. | |
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 | |
22 namespace boost { | |
23 namespace interprocess { | |
24 namespace ipcdetail { | |
25 | |
26 template <class T, T val> | |
27 struct integral_constant | |
28 { | |
29 static const T value = val; | |
30 typedef integral_constant<T,val> type; | |
31 }; | |
32 | |
33 template< bool C_ > | |
34 struct bool_ : integral_constant<bool, C_> | |
35 { | |
36 static const bool value = C_; | |
37 }; | |
38 | |
39 typedef bool_<true> true_; | |
40 typedef bool_<false> false_; | |
41 | |
42 typedef true_ true_type; | |
43 typedef false_ false_type; | |
44 | |
45 typedef char yes_type; | |
46 struct no_type | |
47 { | |
48 char padding[8]; | |
49 }; | |
50 | |
51 template <bool B, class T = void> | |
52 struct enable_if_c { | |
53 typedef T type; | |
54 }; | |
55 | |
56 template <class T> | |
57 struct enable_if_c<false, T> {}; | |
58 | |
59 template <class Cond, class T = void> | |
60 struct enable_if : public enable_if_c<Cond::value, T> {}; | |
61 | |
62 template <class Cond, class T = void> | |
63 struct disable_if : public enable_if_c<!Cond::value, T> {}; | |
64 | |
65 template <class T, class U> | |
66 class 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 static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t); | |
75 }; | |
76 | |
77 template< | |
78 bool C | |
79 , typename T1 | |
80 , typename T2 | |
81 > | |
82 struct if_c | |
83 { | |
84 typedef T1 type; | |
85 }; | |
86 | |
87 template< | |
88 typename T1 | |
89 , typename T2 | |
90 > | |
91 struct if_c<false,T1,T2> | |
92 { | |
93 typedef T2 type; | |
94 }; | |
95 | |
96 template< | |
97 typename T1 | |
98 , typename T2 | |
99 , typename T3 | |
100 > | |
101 struct if_ | |
102 { | |
103 typedef typename if_c<0 != T1::value, T2, T3>::type type; | |
104 }; | |
105 | |
106 | |
107 template <class Pair> | |
108 struct 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. | |
120 template <class T> | |
121 struct 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 | |
129 template<std::size_t S> | |
130 struct ls_zeros | |
131 { | |
132 static const std::size_t value = (S & std::size_t(1)) ? 0 : (1u + ls_zeros<(S >> 1u)>::value); | |
133 }; | |
134 | |
135 template<> | |
136 struct ls_zeros<0> | |
137 { | |
138 static const std::size_t value = 0; | |
139 }; | |
140 | |
141 template<> | |
142 struct ls_zeros<1> | |
143 { | |
144 static const std::size_t value = 0; | |
145 }; | |
146 | |
147 } //namespace ipcdetail { | |
148 } //namespace interprocess { | |
149 } //namespace boost { | |
150 | |
151 #endif //#ifndef BOOST_INTERPROCESS_DETAIL_MPL_HPP | |
152 |