src/util/bitset_getdata/lib.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "../util/lib.hpp" | ||
| 4 | |||
| 5 | namespace tifa_libs { | ||
| 6 | |||
| 7 | template <size_t N> | ||
| 8 | struct bitset_getdata { | ||
| 9 | using word_t = std::_Base_bitset<2>::_WordT; | ||
| 10 | static CEXP size_t Nw = (N / (8 * sizeof(word_t)) + !!(N % (8 * sizeof(word_t)))); | ||
| 11 | static_assert(Nw > 0); | ||
| 12 | |||
| 13 | 102285888 | static CEXP word_t* getdata(std::bitset<N>& x) NE { | |
| 14 | 102285888 | if CEXP (Nw == 1) return &(c_(x)->_M_w); | |
| 15 | else return c_(x)->_M_w; | ||
| 16 | } | ||
| 17 | static CEXP auto getdata(std::bitset<N> CR x) NE { return cc_(x)->_M_getdata(); } | ||
| 18 | 89614175 | static CEXP word_t& getword(std::bitset<N>& x, size_t pos) NE { return c_(x)->_M_getword(pos); } | |
| 19 | 140757075 | static CEXP word_t getword(std::bitset<N> CR x, size_t pos) NE { return cc_(x)->_M_getword(pos); } | |
| 20 | |||
| 21 | private: | ||
| 22 | 191900063 | static CEXP auto c_(std::bitset<N>& x) NE { return (std::_Base_bitset<Nw>*)(&x); } | |
| 23 | 140757075 | static CEXP auto cc_(std::bitset<N> CR x) NE { return (std::_Base_bitset<Nw> const*)(&x); } | |
| 24 | }; | ||
| 25 | |||
| 26 | } // namespace tifa_libs | ||
| 27 |