comparison DEPENDENCIES/generic/include/boost/lockfree/detail/parameter.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children
comparison
equal deleted inserted replaced
15:663ca0da4350 16:2665513ce2d3
1 // boost lockfree
2 //
3 // Copyright (C) 2011 Tim Blechmann
4 //
5 // Distributed under the Boost Software License, Version 1.0. (See
6 // accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8
9 #ifndef BOOST_LOCKFREE_DETAIL_PARAMETER_HPP
10 #define BOOST_LOCKFREE_DETAIL_PARAMETER_HPP
11
12 #include <boost/lockfree/policies.hpp>
13
14 namespace boost {
15 namespace lockfree {
16 namespace detail {
17
18 namespace mpl = boost::mpl;
19
20 template <typename bound_args, typename tag_type>
21 struct has_arg
22 {
23 typedef typename parameter::binding<bound_args, tag_type, mpl::void_>::type type;
24 static const bool value = mpl::is_not_void_<type>::type::value;
25 };
26
27
28 template <typename bound_args>
29 struct extract_capacity
30 {
31 static const bool has_capacity = has_arg<bound_args, tag::capacity>::value;
32
33 typedef typename mpl::if_c<has_capacity,
34 typename has_arg<bound_args, tag::capacity>::type,
35 mpl::size_t< 0 >
36 >::type capacity_t;
37
38 static const std::size_t capacity = capacity_t::value;
39 };
40
41
42 template <typename bound_args, typename T>
43 struct extract_allocator
44 {
45 static const bool has_allocator = has_arg<bound_args, tag::allocator>::value;
46
47 typedef typename mpl::if_c<has_allocator,
48 typename has_arg<bound_args, tag::allocator>::type,
49 std::allocator<T>
50 >::type allocator_arg;
51
52 typedef typename allocator_arg::template rebind<T>::other type;
53 };
54
55 template <typename bound_args, bool default_ = false>
56 struct extract_fixed_sized
57 {
58 static const bool has_fixed_sized = has_arg<bound_args, tag::fixed_sized>::value;
59
60 typedef typename mpl::if_c<has_fixed_sized,
61 typename has_arg<bound_args, tag::fixed_sized>::type,
62 mpl::bool_<default_>
63 >::type type;
64
65 static const bool value = type::value;
66 };
67
68
69 } /* namespace detail */
70 } /* namespace lockfree */
71 } /* namespace boost */
72
73 #endif /* BOOST_LOCKFREE_DETAIL_PARAMETER_HPP */