1 #ifndef LIBJMMCG_CORE_BITFIELD_MAP_HPP
2 #define LIBJMMCG_CORE_BITFIELD_MAP_HPP
26 #include <boost/mpl/accumulate.hpp>
27 #include <boost/mpl/assert.hpp>
28 #include <boost/mpl/at.hpp>
29 #include <boost/mpl/begin.hpp>
30 #include <boost/mpl/deref.hpp>
31 #include <boost/mpl/empty.hpp>
32 #include <boost/mpl/find_if.hpp>
33 #include <boost/mpl/int.hpp>
34 #include <boost/mpl/next.hpp>
35 #include <boost/mpl/not.hpp>
36 #include <boost/mpl/placeholders.hpp>
37 #include <boost/mpl/plus.hpp>
38 #include <boost/mpl/size.hpp>
39 #include <boost/mpl/sizeof.hpp>
40 #include <boost/mpl/transform_view.hpp>
47 #include <type_traits>
58 std::size_t BFSz=
sizeof(
typename std::underlying_type<
typename boost::mpl::deref<
typename boost::mpl::begin<BFSM>::type>::type::first::value_type>::type)
62 using key_type=uint64_t;
63 using size_type=
std::size_t;
64 using mapped_types=BFSM;
65 using bitfields_tags_type=
typename boost::mpl::deref<
typename boost::mpl::begin<mapped_types>::type>::type::first::value_type;
66 using underlying_key_type=
typename std::underlying_type<bitfields_tags_type>::type;
71 BOOST_MPL_ASSERT((
std::is_pod<bitfields_tags_type>));
75 BOOST_MPL_ASSERT((
std::is_integral<
typename std::underlying_type<bitfields_tags_type>::type>));
78 range_mapped_types_size=boost::mpl::accumulate<
79 boost::mpl::transform_view<mapped_types, boost::mpl::sizeof_<boost::mpl::second<boost::mpl::_1>>>,
80 boost::mpl::int_<0u>::type,
81 boost::mpl::plus<boost::mpl::_1, boost::mpl::_2>
84 mapped_types_size=
boost::mpl::size<mapped_types>::value
87 using raw_mapped_data_t=
std::array<uint8_t, range_mapped_types_size>;
90 using raw_key_type_t=
std::array<uint8_t, bitfields_size>;
95 typename boost::mpl::find_if<
99 typename boost::mpl::end<mapped_types>::type
103 BOOST_MPL_ASSERT_RELATION(
sizeof(bitfields_tags_type), <=,
sizeof(key_type));
104 BOOST_MPL_ASSERT_RELATION(
sizeof(underlying_key_type), ==,
sizeof(bitfields_tags_type));
105 BOOST_MPL_ASSERT_RELATION(range_mapped_types_size, >, 0);
106 BOOST_MPL_ASSERT_RELATION(boost::mpl::empty<mapped_types>::value, !=,
true);
186 bitfields_tags_type SelectedField,
188 class Ret=
typename boost::mpl::at<mapped_types, AsType>::type
199 bitfields_tags_type SelectedField,
201 class Ret=
typename boost::mpl::at<mapped_types, AsType>::type
214 bitfields_tags_type SelectedField,
216 class Ret=
typename boost::mpl::at<mapped_types, AsType>::type
226 template<bitfields_tags_type SelectedField>
238 bitfields_tags_type SelectedField,
240 class Arg=
typename boost::mpl::at<mapped_types, AsType>::type
258 key_type
constexpr convert_to_biggest_integral_type()
const noexcept(
true);
261 raw_mapped_data_t raw_mapped_data;
262 }
__attribute__((packed));