File indexing completed on 2025-09-16 08:37:46
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
0018 #include <type_traits>
0019
0020 namespace boost { namespace lockfree { namespace detail {
0021
0022
0023
0024 template < typename bound_args, typename tag_type, typename default_ >
0025 using extract_arg_or_default_t = typename parameter::binding< bound_args, tag_type, default_ >::type;
0026
0027
0028 template < typename BoundArgs, typename TypeTag, typename IntegralType, IntegralType default_ = IntegralType {} >
0029 struct extract_integral_arg_or_default_t
0030 {
0031 static constexpr IntegralType value
0032 = extract_arg_or_default_t< BoundArgs, TypeTag, std::integral_constant< IntegralType, default_ > >::value;
0033 };
0034
0035
0036 struct no_such_parameter_t
0037 {};
0038
0039 template < typename bound_args, typename tag_type >
0040 using has_no_arg_t
0041 = std::is_same< extract_arg_or_default_t< bound_args, tag_type, no_such_parameter_t >, no_such_parameter_t >;
0042
0043
0044
0045 template < typename bound_args >
0046 struct extract_capacity
0047 {
0048 using capacity_t = extract_arg_or_default_t< bound_args, tag::capacity, std::integral_constant< size_t, 0 > >;
0049 using has_no_capacity_t = has_no_arg_t< bound_args, tag::capacity >;
0050 static constexpr std::size_t capacity = capacity_t::value;
0051 static constexpr bool has_capacity = !has_no_capacity_t::value;
0052 };
0053
0054 template < typename bound_args >
0055 using extract_capacity_t = typename extract_capacity< bound_args >::type;
0056
0057
0058
0059 template < typename bound_args, typename T >
0060 struct extract_allocator
0061 {
0062 using default_allocator = boost::alignment::aligned_allocator< T, cacheline_bytes >;
0063 using allocator_t = extract_arg_or_default_t< bound_args, tag::allocator, default_allocator >;
0064
0065 using has_no_allocator_t = has_no_arg_t< bound_args, tag::allocator >;
0066 static constexpr bool has_allocator = !has_no_allocator_t::value;
0067
0068 typedef typename boost::allocator_rebind< allocator_t, T >::type type;
0069 };
0070
0071 template < typename bound_args, typename T >
0072 using extract_allocator_t = typename extract_allocator< bound_args, T >::type;
0073
0074
0075
0076 template < typename bound_args, bool default_ = false >
0077 using extract_fixed_sized = extract_integral_arg_or_default_t< bound_args, tag::fixed_sized, bool, default_ >;
0078
0079
0080
0081 template < typename bound_args, bool default_ = false >
0082 using extract_allow_multiple_reads
0083 = extract_integral_arg_or_default_t< bound_args, tag::allow_multiple_reads, bool, default_ >;
0084
0085
0086
0087 }}}
0088
0089 #endif