File indexing completed on 2025-01-18 09:39:17
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_LOCKFREE_DETAIL_PARAMETER_HPP
0010 #define BOOST_LOCKFREE_DETAIL_PARAMETER_HPP
0011
0012 #include <boost/align/aligned_allocator.hpp>
0013 #include <boost/core/allocator_access.hpp>
0014 #include <boost/lockfree/detail/prefix.hpp>
0015 #include <boost/lockfree/policies.hpp>
0016 #include <boost/parameter/binding.hpp>
0017 #include <boost/parameter/parameters.hpp>
0018
0019 #include <boost/mpl/void.hpp>
0020
0021
0022
0023 namespace boost {
0024 namespace lockfree {
0025 namespace detail {
0026
0027 namespace mpl = boost::mpl;
0028
0029 template <typename bound_args, typename tag_type>
0030 struct has_arg
0031 {
0032 typedef typename parameter::binding<bound_args, tag_type, mpl::void_>::type type;
0033 static const bool value = mpl::is_not_void_<type>::type::value;
0034 };
0035
0036
0037 template <typename bound_args>
0038 struct extract_capacity
0039 {
0040 static const bool has_capacity = has_arg<bound_args, tag::capacity>::value;
0041
0042 typedef typename mpl::if_c<has_capacity,
0043 typename has_arg<bound_args, tag::capacity>::type,
0044 mpl::size_t< 0 >
0045 >::type capacity_t;
0046
0047 static const std::size_t capacity = capacity_t::value;
0048 };
0049
0050
0051 template <typename bound_args, typename T>
0052 struct extract_allocator
0053 {
0054 static const bool has_allocator = has_arg<bound_args, tag::allocator>::value;
0055
0056 typedef typename mpl::if_c<has_allocator,
0057 typename has_arg<bound_args, tag::allocator>::type,
0058 boost::alignment::aligned_allocator<T, BOOST_LOCKFREE_CACHELINE_BYTES>
0059 >::type allocator_arg;
0060
0061 typedef typename boost::allocator_rebind<allocator_arg, T>::type type;
0062 };
0063
0064 template <typename bound_args, bool default_ = false>
0065 struct extract_fixed_sized
0066 {
0067 static const bool has_fixed_sized = has_arg<bound_args, tag::fixed_sized>::value;
0068
0069 typedef typename mpl::if_c<has_fixed_sized,
0070 typename has_arg<bound_args, tag::fixed_sized>::type,
0071 mpl::bool_<default_>
0072 >::type type;
0073
0074 static const bool value = type::value;
0075 };
0076
0077
0078 }
0079 }
0080 }
0081
0082 #endif