1 #ifndef __CT_BITSET_CXX17_HPP_INCLUDED__
2 #define __CT_BITSET_CXX17_HPP_INCLUDED__
40 template<
typename _Ty,
typename u_type = u
int64_t>
41 class range:
private std::pair<u_type, u_type>
44 using _MyBase = std::pair<u_type, u_type>;
81 constexpr
range(_Ty _first, _Ty _last) :
_MyBase{static_cast<u_type>(_first), static_cast<u_type>(_last)}
95 template<
typename _Ty>
101 template<
class _Ty,
size_t _Size,
class u_type>
106 static constexpr
size_t width = 8 *
sizeof(_Ty);
107 static constexpr
size_t max_width = 8 *
sizeof(_Ty) * _Size;
109 static constexpr
bool IsYes(
char c) {
return c ==
'1'; }
110 static constexpr
bool IsYes(
bool c) {
return c; }
112 template<
typename _Other>
115 size_t _Pos =
static_cast<size_t>(_v);
124 template<
typename _Other>
128 for (
auto value: args) {
134 template<
typename _Iterator>
138 for (
auto it = begin; it != end; ++it) {
140 auto offset = std::distance(begin, it);
164 for (
auto it:
range(from, to))
183 constexpr
uint64_t m1 = 0x5555555555555555;
184 constexpr
uint64_t m2 = 0x3333333333333333;
185 constexpr
uint64_t m4 = 0x0f0f0f0f0f0f0f0f;
189 constexpr
uint64_t h01 = 0x0101010101010101;
192 x = (x & m2) + ((x >> 2) & m2);
193 x = (x + (x >> 4)) & m4;
194 return int((x * h01) >> 56);
214 auto only_low_bits = x ^ (x - 1);
224 template<
size_t _Bits,
class T>
259 using std::pair<T, T>::pair;
271 static constexpr
size_t capacity() {
return _Bits; }
324 size_t _Pos =
static_cast<size_t>(_v);
329 bool previous = (
val &
mask) != 0;
337 size_t _Pos =
static_cast<size_t>(_v);
342 bool previous = (
val &
mask) != 0;
351 size_t _Pos =
static_cast<size_t>(_v);
356 bool previous = (
val &
mask) != 0;
417 if (current &
_Ty(1)) {
424 if constexpr (
_Words > 1) {
451 if (current &
_Ty(1)) {
468 constexpr const_iterator
cbegin()
const noexcept {
return const_iterator(
this, std::true_type{}); }
469 constexpr const_iterator
cend()
const noexcept {
return const_iterator(
this, std::false_type{}); }
473 template<
class _Ty,
class _Alloc>
474 operator std::vector<_Ty, _Alloc>()
const
476 std::vector<_Ty, _Alloc> vec;
499 throw std::out_of_range(
"invalid const_bitset<_Bits, T> position");
constexpr T operator*() const
constexpr const_iterator(const const_bitset *_this, std::false_type)
const const_bitset * m_bitset
constexpr bool operator!=(const const_iterator &o) const
constexpr const_iterator operator++(int)
constexpr T operator->() const
constexpr bool operator==(const const_iterator &o) const
constexpr const_iterator & operator++()
constexpr void x_find_next_bit()
const eTestNames & reference
constexpr const_iterator(const const_bitset *_this, std::true_type)
std::forward_iterator_tag iterator_category
constexpr const_iterator()=default
const eTestNames * pointer
constexpr const_bitset(T _init)
constexpr const_iterator cend() const noexcept
typename real_underlying_type< eTestNames >::type u_type
constexpr const_bitset(char const (&_init)[N])
constexpr const_iterator end() const noexcept
constexpr const_iterator begin() const noexcept
constexpr const_bitset()=default
static constexpr size_t capacity()
constexpr bool test(T _Pos) const
constexpr const_iterator cbegin() const noexcept
static constexpr size_t _Bitsperword
static constexpr const_bitset set_range(T _from, T _to)
constexpr bool ct_set(T _v)
constexpr bool x_test(size_t _Pos) const
constexpr size_t size() const
constexpr bool _Subscript(size_t _Pos) const
constexpr bool empty() const
const_bitset & operator-=(T value)
constexpr const_bitset(const _Array_t &args)
const_array< _Ty, _Words > _Array_t
constexpr const_bitset(std::initializer_list< T > _init)
const_bitset & operator+=(T value)
constexpr const_bitset(const range &_range)
constexpr const_bitset(const const_array< char, N > &_init)
static constexpr size_t _Words
constexpr bool ct_test(T _Pos) const
constexpr const_iterator()=default
constexpr _Ty operator*() noexcept
constexpr bool operator!=(const const_iterator &o) const
constexpr const_iterator operator++(int)
constexpr const_iterator & operator++()
constexpr bool operator==(const const_iterator &o) const
constexpr const_iterator(u_type v)
constexpr _Ty operator->() noexcept
constexpr range()=default
constexpr const_iterator begin() const noexcept
constexpr const_iterator end() const noexcept
constexpr const_iterator cend() const noexcept
constexpr const_iterator cbegin() const noexcept
constexpr range(_Ty _first, _Ty _last)
std::pair< u_type, u_type > _MyBase
static vector< string > arr
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
unsigned int
A callback function used to compare two keys in a database.
constexpr int popcount64c(uint64_t x)
range(_Ty, _Ty) -> range< _Ty >
constexpr size_t find_first_bit(uint64_t x)
constexpr int popcount64d(uint64_t x)
const GenericPointer< typename T::ValueType > T2 value
std::istream & in(std::istream &in_, double &x_)
Int4 delta(size_t dimension_, const Int4 *score_)
static constexpr bool IsYes(bool c)
static constexpr array_t set_bits(const const_array< char, N > &in)
static constexpr array_t set_bits(std::initializer_list< _Other > args)
static constexpr size_t width
static constexpr void ct_set(array_t &arr, _Other _v)
static constexpr bool IsYes(char c)
static constexpr array_t set_bits(const const_array< bool, N > &in)
const_array< _Ty, _Size > array_t
static constexpr array_t set_range(T from, T to)
static constexpr size_t max_width
static constexpr array_t set_bits(_Iterator begin, _Iterator end)