Chris@16
|
1 // boost lockfree
|
Chris@16
|
2 //
|
Chris@16
|
3 // Copyright (C) 2011 Tim Blechmann
|
Chris@16
|
4 //
|
Chris@16
|
5 // Distributed under the Boost Software License, Version 1.0. (See
|
Chris@16
|
6 // 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 #ifndef BOOST_LOCKFREE_DETAIL_PARAMETER_HPP
|
Chris@16
|
10 #define BOOST_LOCKFREE_DETAIL_PARAMETER_HPP
|
Chris@16
|
11
|
Chris@16
|
12 #include <boost/lockfree/policies.hpp>
|
Chris@16
|
13
|
Chris@16
|
14 namespace boost {
|
Chris@16
|
15 namespace lockfree {
|
Chris@16
|
16 namespace detail {
|
Chris@16
|
17
|
Chris@16
|
18 namespace mpl = boost::mpl;
|
Chris@16
|
19
|
Chris@16
|
20 template <typename bound_args, typename tag_type>
|
Chris@16
|
21 struct has_arg
|
Chris@16
|
22 {
|
Chris@16
|
23 typedef typename parameter::binding<bound_args, tag_type, mpl::void_>::type type;
|
Chris@16
|
24 static const bool value = mpl::is_not_void_<type>::type::value;
|
Chris@16
|
25 };
|
Chris@16
|
26
|
Chris@16
|
27
|
Chris@16
|
28 template <typename bound_args>
|
Chris@16
|
29 struct extract_capacity
|
Chris@16
|
30 {
|
Chris@16
|
31 static const bool has_capacity = has_arg<bound_args, tag::capacity>::value;
|
Chris@16
|
32
|
Chris@16
|
33 typedef typename mpl::if_c<has_capacity,
|
Chris@16
|
34 typename has_arg<bound_args, tag::capacity>::type,
|
Chris@16
|
35 mpl::size_t< 0 >
|
Chris@16
|
36 >::type capacity_t;
|
Chris@16
|
37
|
Chris@16
|
38 static const std::size_t capacity = capacity_t::value;
|
Chris@16
|
39 };
|
Chris@16
|
40
|
Chris@16
|
41
|
Chris@16
|
42 template <typename bound_args, typename T>
|
Chris@16
|
43 struct extract_allocator
|
Chris@16
|
44 {
|
Chris@16
|
45 static const bool has_allocator = has_arg<bound_args, tag::allocator>::value;
|
Chris@16
|
46
|
Chris@16
|
47 typedef typename mpl::if_c<has_allocator,
|
Chris@16
|
48 typename has_arg<bound_args, tag::allocator>::type,
|
Chris@16
|
49 std::allocator<T>
|
Chris@16
|
50 >::type allocator_arg;
|
Chris@16
|
51
|
Chris@16
|
52 typedef typename allocator_arg::template rebind<T>::other type;
|
Chris@16
|
53 };
|
Chris@16
|
54
|
Chris@16
|
55 template <typename bound_args, bool default_ = false>
|
Chris@16
|
56 struct extract_fixed_sized
|
Chris@16
|
57 {
|
Chris@16
|
58 static const bool has_fixed_sized = has_arg<bound_args, tag::fixed_sized>::value;
|
Chris@16
|
59
|
Chris@16
|
60 typedef typename mpl::if_c<has_fixed_sized,
|
Chris@16
|
61 typename has_arg<bound_args, tag::fixed_sized>::type,
|
Chris@16
|
62 mpl::bool_<default_>
|
Chris@16
|
63 >::type type;
|
Chris@16
|
64
|
Chris@16
|
65 static const bool value = type::value;
|
Chris@16
|
66 };
|
Chris@16
|
67
|
Chris@16
|
68
|
Chris@16
|
69 } /* namespace detail */
|
Chris@16
|
70 } /* namespace lockfree */
|
Chris@16
|
71 } /* namespace boost */
|
Chris@16
|
72
|
Chris@16
|
73 #endif /* BOOST_LOCKFREE_DETAIL_PARAMETER_HPP */
|