magic_enum_containers.hpp
Go to the documentation of this file.
1 // __ __ _ ______ _____
2 // | \/ | (_) | ____| / ____|_ _
3 // | \ / | __ _ __ _ _ ___ | |__ _ __ _ _ _ __ ___ | | _| |_ _| |_
4 // | |\/| |/ _` |/ _` | |/ __| | __| | '_ \| | | | '_ ` _ \ | | |_ _|_ _|
5 // | | | | (_| | (_| | | (__ | |____| | | | |_| | | | | | | | |____|_| |_|
6 // |_| |_|\__,_|\__, |_|\___| |______|_| |_|\__,_|_| |_| |_| \_____|
7 // __/ | https://github.com/Neargye/magic_enum
8 // |___/ version 0.9.7
9 //
10 // Licensed under the MIT License <http://opensource.org/licenses/MIT>.
11 // SPDX-License-Identifier: MIT
12 // Copyright (c) 2019 - 2024 Daniil Goncharov <neargye@gmail.com>.
13 // Copyright (c) 2022 - 2023 Bela Schaum <schaumb@gmail.com>.
14 //
15 // Permission is hereby granted, free of charge, to any person obtaining a copy
16 // of this software and associated documentation files (the "Software"), to deal
17 // in the Software without restriction, including without limitation the rights
18 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19 // copies of the Software, and to permit persons to whom the Software is
20 // furnished to do so, subject to the following conditions:
21 //
22 // The above copyright notice and this permission notice shall be included in all
23 // copies or substantial portions of the Software.
24 //
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 // SOFTWARE.
32 
33 #ifndef NEARGYE_MAGIC_ENUM_CONTAINERS_HPP
34 #define NEARGYE_MAGIC_ENUM_CONTAINERS_HPP
35 
36 #include "magic_enum.hpp"
37 
38 #if !defined(MAGIC_ENUM_NO_EXCEPTION) && (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND))
39 #ifndef MAGIC_ENUM_USE_STD_MODULE
40 # include <stdexcept>
41 #endif
42 # define MAGIC_ENUM_THROW(...) throw (__VA_ARGS__)
43 #else
44 #ifndef MAGIC_ENUM_USE_STD_MODULE
45 # include <cstdlib>
46 #endif
47 # define MAGIC_ENUM_THROW(...) std::abort()
48 #endif
49 
51 
52 namespace detail {
53 
54 template <typename T, typename = void>
55 inline constexpr bool is_transparent_v{};
56 
57 template <typename T>
58 inline constexpr bool is_transparent_v<T, std::void_t<typename T::is_transparent>>{true};
59 
60 template <typename Eq = std::equal_to<>, typename T1, typename T2>
61 constexpr bool equal(T1&& t1, T2&& t2, Eq&& eq = {}) {
62  auto first1 = t1.begin();
63  auto last1 = t1.end();
64  auto first2 = t2.begin();
65  auto last2 = t2.end();
66 
67  for (; first1 != last1; ++first1, ++first2) {
68  if (first2 == last2 || !eq(*first1, *first2)) {
69  return false;
70  }
71  }
72  return first2 == last2;
73 }
74 
75 template <typename Cmp = std::less<>, typename T1, typename T2>
76 constexpr bool lexicographical_compare(T1&& t1, T2&& t2, Cmp&& cmp = {}) noexcept {
77  auto first1 = t1.begin();
78  auto last1 = t1.end();
79  auto first2 = t2.begin();
80  auto last2 = t2.end();
81 
82  // copied from std::lexicographical_compare
83  for (; (first1 != last1) && (first2 != last2); ++first1, (void)++first2) {
84  if (cmp(*first1, *first2)) {
85  return true;
86  }
87  if (cmp(*first2, *first1)) {
88  return false;
89  }
90  }
91  return (first1 == last1) && (first2 != last2);
92 }
93 
94 template <typename T>
95 constexpr std::size_t popcount(T x) noexcept {
96  std::size_t c = 0;
97  while (x > 0) {
98  c += x & 1;
99  x >>= 1;
100  }
101  return c;
102 }
103 
104 template <typename Cmp = std::less<>, typename ForwardIt, typename E>
105 constexpr ForwardIt lower_bound(ForwardIt first, ForwardIt last, E&& e, Cmp&& comp = {}) {
106  auto count = std::distance(first, last);
107  for (auto it = first; count > 0;) {
108  auto step = count / 2;
109  std::advance(it, step);
110  if (comp(*it, e)) {
111  first = ++it;
112  count -= step + 1;
113  } else {
114  count = step;
115  }
116  }
117  return first;
118 }
119 
120 template <typename Cmp = std::less<>, typename BidirIt, typename E>
121 constexpr auto equal_range(BidirIt begin, BidirIt end, E&& e, Cmp&& comp = {}) {
122  const auto first = lower_bound(begin, end, e, comp);
123  return std::pair{first, lower_bound(std::make_reverse_iterator(end), std::make_reverse_iterator(first), e, [&comp](auto&& lhs, auto&& rhs) { return comp(rhs, lhs); }).base()};
124 }
125 
126 template <typename E = void, typename Cmp = std::less<E>, typename = void>
127 class indexing {
128  [[nodiscard]] static constexpr auto get_indices() noexcept {
129  // reverse result index mapping
130  std::array<std::size_t, enum_count<E>()> rev_res{};
131 
132  // std::iota
133  for (std::size_t i = 0; i < enum_count<E>(); ++i) {
134  rev_res[i] = i;
135  }
136 
137  constexpr auto orig_values = enum_values<E>();
138  constexpr Cmp cmp{};
139 
140  // ~std::sort
141  for (std::size_t i = 0; i < enum_count<E>(); ++i) {
142  for (std::size_t j = i + 1; j < enum_count<E>(); ++j) {
143  if (cmp(orig_values[rev_res[j]], orig_values[rev_res[i]])) {
144  auto tmp = rev_res[i];
145  rev_res[i] = rev_res[j];
146  rev_res[j] = tmp;
147  }
148  }
149  }
150 
151  std::array<E, enum_count<E>()> sorted_values{};
152  // reverse the sorted indices
153  std::array<std::size_t, enum_count<E>()> res{};
154  for (std::size_t i = 0; i < enum_count<E>(); ++i) {
155  res[rev_res[i]] = i;
156  sorted_values[i] = orig_values[rev_res[i]];
157  }
158 
159  return std::pair{sorted_values, res};
160  }
161 
162  static constexpr auto indices = get_indices();
163 
164  public:
165  [[nodiscard]] static constexpr const E* begin() noexcept { return indices.first.data(); }
166 
167  [[nodiscard]] static constexpr const E* end() noexcept { return indices.first.data() + indices.first.size(); }
168 
169  [[nodiscard]] static constexpr const E* it(std::size_t i) noexcept { return indices.first.data() + i; }
170 
171  [[nodiscard]] static constexpr optional<std::size_t> at(E val) noexcept {
172  if (auto i = enum_index(val)) {
173  return indices.second[*i];
174  }
175  return {};
176  }
177 };
178 
179 template <typename E, typename Cmp>
180 class indexing<E, Cmp, std::enable_if_t<std::is_enum_v<std::decay_t<E>> && (std::is_same_v<Cmp, std::less<E>> || std::is_same_v<Cmp, std::less<>>)>> {
181  static constexpr auto& values = enum_values<E>();
182 
183  public:
184  [[nodiscard]] static constexpr const E* begin() noexcept { return values.data(); }
185 
186  [[nodiscard]] static constexpr const E* end() noexcept { return values.data() + values.size(); }
187 
188  [[nodiscard]] static constexpr const E* it(std::size_t i) noexcept { return values.data() + i; }
189 
190  [[nodiscard]] static constexpr optional<std::size_t> at(E val) noexcept { return enum_index(val); }
191 };
192 
193 template <typename Cmp>
194 struct indexing<void, Cmp, void> {
195  using is_transparent = std::true_type;
196 
197  template <typename E>
198  [[nodiscard]] static constexpr optional<std::size_t> at(E val) noexcept {
199  return indexing<E, Cmp>::at(val);
200  }
201 };
202 
203 template <typename E = void, typename Cmp = std::less<>, typename = void>
205  [[nodiscard]] constexpr bool operator()(E e1, E e2) const noexcept { return Cmp{}(enum_name(e1), enum_name(e2)); }
206 };
207 
208 template <typename Cmp>
209 struct name_sort_impl<void, Cmp> {
210  using is_transparent = std::true_type;
211 
212  template <typename C = Cmp, typename = void>
213  struct FullCmp : C {};
214 
215  template <typename C>
216  struct FullCmp<C, std::enable_if_t<!std::is_invocable_v<C, string_view, string_view> && std::is_invocable_v<C, char_type, char_type>>> {
217  [[nodiscard]] constexpr bool operator()(string_view s1, string_view s2) const noexcept { return lexicographical_compare<C>(s1, s2); }
218  };
219 
220  template <typename E1, typename E2>
221  [[nodiscard]] constexpr std::enable_if_t<
222  // at least one of need to be an enum type
223  (std::is_enum_v<std::decay_t<E1>> || std::is_enum_v<std::decay_t<E2>>) &&
224  // if both is enum, only accept if the same enum
225  (!std::is_enum_v<std::decay_t<E1>> || !std::is_enum_v<std::decay_t<E2>> || std::is_same_v<E1, E2>) &&
226  // is invocable with comparator
227  (std::is_invocable_r_v<bool, FullCmp<>, std::conditional_t<std::is_enum_v<std::decay_t<E1>>, string_view, E1>, std::conditional_t<std::is_enum_v<std::decay_t<E2>>, string_view, E2>>),
228  bool>
229  operator()(E1 e1, E2 e2) const noexcept {
230  using D1 = std::decay_t<E1>;
231  using D2 = std::decay_t<E2>;
232  constexpr FullCmp<> cmp{};
233 
234  if constexpr (std::is_enum_v<D1> && std::is_enum_v<D2>) {
235  return cmp(enum_name(e1), enum_name(e2));
236  } else if constexpr (std::is_enum_v<D1>) {
237  return cmp(enum_name(e1), e2);
238  } else /* if constexpr (std::is_enum_v<D2>) */ {
239  return cmp(e1, enum_name(e2));
240  }
241  }
242 };
243 
244 struct raw_access_t {};
245 
246 template <typename Parent, typename Iterator, typename Getter, typename Predicate>
248  Parent parent;
249  Iterator first;
250  Iterator last;
251  Iterator current;
252  Getter getter;
254 
255  using iterator_category = std::bidirectional_iterator_tag;
256  using value_type = std::remove_reference_t<std::invoke_result_t<Getter, Parent, Iterator>>;
257  using difference_type = std::ptrdiff_t;
258  using pointer = value_type*;
260 
261  constexpr FilteredIterator() noexcept = default;
262  constexpr FilteredIterator(const FilteredIterator&) = default;
263  constexpr FilteredIterator& operator=(const FilteredIterator&) = default;
264  constexpr FilteredIterator(FilteredIterator&&) noexcept = default;
265  constexpr FilteredIterator& operator=(FilteredIterator&&) noexcept = default;
266 
267  template <typename OtherParent, typename OtherIterator, typename = std::enable_if_t<std::is_convertible_v<OtherParent, Parent> && std::is_convertible_v<OtherIterator, Iterator>>*>
268  constexpr explicit FilteredIterator(const FilteredIterator<OtherParent, OtherIterator, Getter, Predicate>& other)
269  : parent(other.parent), first(other.first), last(other.last), current(other.current), getter(other.getter), predicate(other.predicate) {}
270 
271  constexpr FilteredIterator(Parent p, Iterator begin, Iterator end, Iterator curr, Getter get = {}, Predicate pred = {})
272  : parent(p), first(std::move(begin)), last(std::move(end)), current(std::move(curr)), getter{std::move(get)}, predicate{std::move(pred)} {
273  if (current == first && !predicate(parent, current)) {
274  ++*this;
275  }
276  }
277 
278  [[nodiscard]] constexpr reference operator*() const { return getter(parent, current); }
279 
280  [[nodiscard]] constexpr pointer operator->() const { return std::addressof(**this); }
281 
283  do {
284  ++current;
285  } while (current != last && !predicate(parent, current));
286  return *this;
287  }
288 
289  [[nodiscard]] constexpr FilteredIterator operator++(int) {
290  FilteredIterator cp = *this;
291  ++*this;
292  return cp;
293  }
294 
296  do {
297  --current;
298  } while (current != first && !predicate(parent, current));
299  return *this;
300  }
301 
302  [[nodiscard]] constexpr FilteredIterator operator--(int) {
303  FilteredIterator cp = *this;
304  --*this;
305  return cp;
306  }
307 
308  [[nodiscard]] friend constexpr bool operator==(const FilteredIterator& lhs, const FilteredIterator& rhs) { return lhs.current == rhs.current; }
309 
310  [[nodiscard]] friend constexpr bool operator!=(const FilteredIterator& lhs, const FilteredIterator& rhs) { return lhs.current != rhs.current; }
311 };
312 
313 } // namespace detail
314 
315 template <typename E = void>
317 
318 template <typename E = void>
320 
322 
324 
325 template <typename E = void>
327 
328 template <typename Cmp = std::less<>>
330 
332 // ARRAY //
334 template <typename E, typename V, typename Index = default_indexing<E>>
335 struct array {
336  static_assert(std::is_enum_v<E>);
337  static_assert(std::is_trivially_constructible_v<Index>);
338  static_assert(enum_count<E>() > 0 && Index::at(enum_values<E>().front()));
339 
340  using index_type = Index;
341  using container_type = std::array<V, enum_count<E>()>;
342 
343  using value_type = typename container_type::value_type;
344  using size_type = typename container_type::size_type;
345  using difference_type = typename container_type::difference_type;
346  using reference = typename container_type::reference;
347  using const_reference = typename container_type::const_reference;
348  using pointer = typename container_type::pointer;
349  using const_pointer = typename container_type::const_pointer;
350  using iterator = typename container_type::iterator;
351  using const_iterator = typename container_type::const_iterator;
352  using reverse_iterator = typename container_type::reverse_iterator;
353  using const_reverse_iterator = typename container_type::const_reverse_iterator;
354 
355  constexpr reference at(E pos) {
356  if (auto index = index_type::at(pos)) {
357  return a[*index];
358  }
359  MAGIC_ENUM_THROW(std::out_of_range("magic_enum::containers::array::at Unrecognized position"));
360  }
361 
362  constexpr const_reference at(E pos) const {
363  if (auto index = index_type::at(pos)) {
364  return a[*index];
365  }
366  MAGIC_ENUM_THROW(std::out_of_range("magic_enum::containers::array::at: Unrecognized position"));
367  }
368 
369  [[nodiscard]] constexpr reference operator[](E pos) {
370  auto i = index_type::at(pos);
371  return MAGIC_ENUM_ASSERT(i), a[*i];
372  }
373 
374  [[nodiscard]] constexpr const_reference operator[](E pos) const {
375  auto i = index_type::at(pos);
376  return MAGIC_ENUM_ASSERT(i), a[*i];
377  }
378 
379  [[nodiscard]] constexpr reference front() noexcept { return a.front(); }
380 
381  [[nodiscard]] constexpr const_reference front() const noexcept { return a.front(); }
382 
383  [[nodiscard]] constexpr reference back() noexcept { return a.back(); }
384 
385  [[nodiscard]] constexpr const_reference back() const noexcept { return a.back(); }
386 
387  [[nodiscard]] constexpr pointer data() noexcept { return a.data(); }
388 
389  [[nodiscard]] constexpr const_pointer data() const noexcept { return a.data(); }
390 
391  [[nodiscard]] constexpr iterator begin() noexcept { return a.begin(); }
392 
393  [[nodiscard]] constexpr const_iterator begin() const noexcept { return a.begin(); }
394 
395  [[nodiscard]] constexpr const_iterator cbegin() const noexcept { return a.cbegin(); }
396 
397  [[nodiscard]] constexpr iterator end() noexcept { return a.end(); }
398 
399  [[nodiscard]] constexpr const_iterator end() const noexcept { return a.end(); }
400 
401  [[nodiscard]] constexpr const_iterator cend() const noexcept { return a.cend(); }
402 
403  [[nodiscard]] constexpr iterator rbegin() noexcept { return a.rbegin(); }
404 
405  [[nodiscard]] constexpr const_iterator rbegin() const noexcept { return a.rbegin(); }
406 
407  [[nodiscard]] constexpr const_iterator crbegin() const noexcept { return a.crbegin(); }
408 
409  [[nodiscard]] constexpr iterator rend() noexcept { return a.rend(); }
410 
411  [[nodiscard]] constexpr const_iterator rend() const noexcept { return a.rend(); }
412 
413  [[nodiscard]] constexpr const_iterator crend() const noexcept { return a.crend(); }
414 
415  [[nodiscard]] constexpr bool empty() const noexcept { return a.empty(); }
416 
417  [[nodiscard]] constexpr size_type size() const noexcept { return a.size(); }
418 
419  [[nodiscard]] constexpr size_type max_size() const noexcept { return a.max_size(); }
420 
421  constexpr void fill(const V& value) {
422  for (auto& v : a) {
423  v = value;
424  }
425  }
426 
427  constexpr void swap(array& other) noexcept(std::is_nothrow_swappable_v<V>) {
428  for (std::size_t i = 0; i < a.size(); ++i) {
429  auto v = std::move(other.a[i]);
430  other.a[i] = std::move(a[i]);
431  a[i] = std::move(v);
432  }
433  }
434 
435  [[nodiscard]] friend constexpr bool operator==(const array& a1, const array& a2) { return detail::equal(a1, a2); }
436 
437  [[nodiscard]] friend constexpr bool operator!=(const array& a1, const array& a2) { return !detail::equal(a1, a2); }
438 
439  [[nodiscard]] friend constexpr bool operator<(const array& a1, const array& a2) { return detail::lexicographical_compare(a1, a2); }
440 
441  [[nodiscard]] friend constexpr bool operator<=(const array& a1, const array& a2) { return !detail::lexicographical_compare(a2, a1); }
442 
443  [[nodiscard]] friend constexpr bool operator>(const array& a1, const array& a2) { return detail::lexicographical_compare(a2, a1); }
444 
445  [[nodiscard]] friend constexpr bool operator>=(const array& a1, const array& a2) { return !detail::lexicographical_compare(a1, a2); }
446 
448 };
449 
450 namespace detail {
451 
452 template <typename E, typename T, std::size_t N, std::size_t... I>
453 constexpr array<E, std::remove_cv_t<T>> to_array_impl(T (&a)[N], std::index_sequence<I...>) {
454  return {{a[I]...}};
455 }
456 
457 template <typename E, typename T, std::size_t N, std::size_t... I>
458 constexpr array<E, std::remove_cv_t<T>> to_array_impl(T(&&a)[N], std::index_sequence<I...>) {
459  return {{std::move(a[I])...}};
460 }
461 
462 } // namespace detail
463 
464 template <typename E, typename T, std::size_t N>
465 constexpr std::enable_if_t<(enum_count<E>() == N), array<E, std::remove_cv_t<T>>> to_array(T (&a)[N]) {
466  return detail::to_array_impl<E>(a, std::make_index_sequence<N>{});
467 }
468 
469 template <typename E, typename T, std::size_t N>
470 constexpr std::enable_if_t<(enum_count<E>() == N), array<E, std::remove_cv_t<T>>> to_array(T(&&a)[N]) {
471  return detail::to_array_impl<E>(std::move(a), std::make_index_sequence<N>{});
472 }
473 
474 template <typename E, typename... Ts>
475 constexpr std::enable_if_t<(enum_count<E>() == sizeof...(Ts)), array<E, std::remove_cv_t<std::common_type_t<Ts...>>>> make_array(Ts&&... ts) {
476  return {{std::forward<Ts>(ts)...}};
477 }
478 
479 inline constexpr detail::raw_access_t raw_access{};
480 
482 // BITSET //
484 template <typename E, typename Index = default_indexing<E>>
485 class bitset {
486  static_assert(std::is_enum_v<E>);
487  static_assert(std::is_trivially_constructible_v<Index>);
488  static_assert(enum_count<E>() > 0 && Index::at(enum_values<E>().front()));
489 
490  using base_type = std::conditional_t<enum_count<E>() <= 8, std::uint_least8_t,
491  std::conditional_t<enum_count<E>() <= 16, std::uint_least16_t,
492  std::conditional_t<enum_count<E>() <= 32, std::uint_least32_t,
493  std::uint_least64_t>>>;
494 
495  static constexpr std::size_t bits_per_base = sizeof(base_type) * 8;
496  static constexpr std::size_t base_type_count = (enum_count<E>() > 0 ? (enum_count<E>() - 1) / bits_per_base + 1 : 0);
497  static constexpr std::size_t not_interested = base_type_count * bits_per_base - enum_count<E>();
498  static constexpr base_type last_value_max = (base_type{1} << (bits_per_base - not_interested)) - 1;
499 
500  template <typename parent_t = bitset*>
502  friend class bitset;
503 
504  parent_t parent;
505  std::size_t num_index;
507 
508  constexpr reference_impl(parent_t p, std::size_t i) noexcept : reference_impl(p, std::pair{i / bits_per_base, base_type{1} << (i % bits_per_base)}) {}
509 
510  constexpr reference_impl(parent_t p, std::pair<std::size_t, base_type> i) noexcept : parent(p), num_index(std::get<0>(i)), bit_index(std::get<1>(i)) {}
511 
512  public:
513  constexpr reference_impl& operator=(bool v) noexcept {
514  if (v) {
515  parent->a[num_index] |= bit_index;
516  } else {
517  parent->a[num_index] &= ~bit_index;
518  }
519  return *this;
520  }
521 
522  constexpr reference_impl& operator=(const reference_impl& v) noexcept {
523  if (this == &v) {
524  return *this;
525  }
526  *this = static_cast<bool>(v);
527  return *this;
528  }
529 
530  [[nodiscard]] constexpr operator bool() const noexcept { return (parent->a[num_index] & bit_index) > 0; }
531 
532  [[nodiscard]] constexpr bool operator~() const noexcept { return !static_cast<bool>(*this); }
533 
534  constexpr reference_impl& flip() noexcept {
535  *this = ~*this;
536  return *this;
537  }
538  };
539 
540  template <typename T>
541  [[nodiscard]] constexpr T to_(detail::raw_access_t) const {
542  T res{};
543  T flag{1};
544  for (std::size_t i = 0; i < size(); ++i, flag <<= 1) {
545  if (const_reference{this, i}) {
546  if (i >= sizeof(T) * 8) {
547  MAGIC_ENUM_THROW(std::overflow_error("magic_enum::containers::bitset::to: Cannot represent enum in this type"));
548  }
549  res |= flag;
550  }
551  }
552  return res;
553  }
554 
555  public:
556  using index_type = Index;
557  using container_type = std::array<base_type, base_type_count>;
558  using reference = reference_impl<>;
559  using const_reference = reference_impl<const bitset*>;
560 
561  constexpr explicit bitset(detail::raw_access_t = raw_access) noexcept : a{{}} {}
562 
563  constexpr explicit bitset(detail::raw_access_t, unsigned long long val) : a{{}} {
564  unsigned long long bit{1};
565  for (std::size_t i = 0; i < (sizeof(val) * 8); ++i, bit <<= 1) {
566  if ((val & bit) > 0) {
567  if (i >= enum_count<E>()) {
568  MAGIC_ENUM_THROW(std::out_of_range("magic_enum::containers::bitset::constructor: Upper bit set in raw number"));
569  }
570 
571  reference{this, i} = true;
572  }
573  }
574  }
575 
576  constexpr explicit bitset(detail::raw_access_t, string_view sv, string_view::size_type pos = 0, string_view::size_type n = string_view::npos, char_type zero = static_cast<char_type>('0'), char_type one = static_cast<char_type>('1'))
577  : a{{}} {
578  std::size_t i = 0;
579  for (auto c : sv.substr(pos, n)) {
580  if (c == one) {
581  if (i >= enum_count<E>()) {
582  MAGIC_ENUM_THROW(std::out_of_range("magic_enum::containers::bitset::constructor: Upper bit set in raw string"));
583  }
584  reference{this, i} = true;
585  } else if (c != zero) {
586  MAGIC_ENUM_THROW(std::invalid_argument("magic_enum::containers::bitset::constructor: Unrecognized character in raw string"));
587  }
588  ++i;
589  }
590  }
591 
592  constexpr explicit bitset(detail::raw_access_t, const char_type* str, std::size_t n = ~std::size_t{0}, char_type zero = static_cast<char_type>('0'), char_type one = static_cast<char_type>('1'))
593  : bitset(string_view{str, (std::min)(std::char_traits<char_type>::length(str), n)}, 0, n, zero, one) {}
594 
595  constexpr bitset(std::initializer_list<E> starters) : a{{}} {
596  if constexpr (magic_enum::detail::subtype_v<E> == magic_enum::detail::enum_subtype::flags) {
597  for (auto& f : starters) {
598  *this |= bitset(f);
599  }
600  } else {
601  for (auto& f : starters) {
602  set(f);
603  }
604  }
605  }
606  template <typename V, std::enable_if_t<std::is_same_v<V, E> && magic_enum::detail::subtype_v<V> == magic_enum::detail::enum_subtype::flags, int> = 0>
607  constexpr explicit bitset(V starter) : a{{}} {
608  auto u = enum_underlying(starter);
609  for (E v : enum_values<E>()) {
610  if (auto ul = enum_underlying(v); (ul & u) != 0) {
611  u &= ~ul;
612  (*this)[v] = true;
613  }
614  }
615  if (u != 0) {
616  MAGIC_ENUM_THROW(std::invalid_argument("magic_enum::containers::bitset::constructor: Unrecognized enum value in flag"));
617  }
618  }
619 
620  template <typename Cmp = std::equal_to<>>
621  constexpr explicit bitset(string_view sv, Cmp&& cmp = {}, char_type sep = static_cast<char_type>('|')) {
622  for (std::size_t to = 0; (to = magic_enum::detail::find(sv, sep)) != string_view::npos; sv.remove_prefix(to + 1)) {
623  if (auto v = enum_cast<E>(sv.substr(0, to), cmp)) {
624  set(*v);
625  } else {
626  MAGIC_ENUM_THROW(std::invalid_argument("magic_enum::containers::bitset::constructor: Unrecognized enum value in string"));
627  }
628  }
629  if (!sv.empty()) {
630  if (auto v = enum_cast<E>(sv, cmp)) {
631  set(*v);
632  } else {
633  MAGIC_ENUM_THROW(std::invalid_argument("magic_enum::containers::bitset::constructor: Unrecognized enum value in string"));
634  }
635  }
636  }
637 
638  [[nodiscard]] friend constexpr bool operator==(const bitset& lhs, const bitset& rhs) noexcept { return detail::equal(lhs.a, rhs.a); }
639 
640  [[nodiscard]] friend constexpr bool operator!=(const bitset& lhs, const bitset& rhs) noexcept { return !detail::equal(lhs.a, rhs.a); }
641 
642  [[nodiscard]] constexpr bool operator[](E pos) const {
643  auto i = index_type::at(pos);
644  return MAGIC_ENUM_ASSERT(i), static_cast<bool>(const_reference(this, *i));
645  }
646 
647  [[nodiscard]] constexpr reference operator[](E pos) {
648  auto i = index_type::at(pos);
649  return MAGIC_ENUM_ASSERT(i), reference{this, *i};
650  }
651 
652  constexpr bool test(E pos) const {
653  if (auto i = index_type::at(pos)) {
654  return static_cast<bool>(const_reference(this, *i));
655  }
656  MAGIC_ENUM_THROW(std::out_of_range("magic_enum::containers::bitset::test: Unrecognized position"));
657  }
658 
659  [[nodiscard]] constexpr bool all() const noexcept {
660  if constexpr (base_type_count == 0) {
661  return true;
662  }
663 
664  for (std::size_t i = 0; i < base_type_count - (not_interested > 0); ++i) {
665  auto check = ~a[i];
666  if (check) {
667  return false;
668  }
669  }
670 
671  if constexpr (not_interested > 0) {
672  return a[base_type_count - 1] == last_value_max;
673  }
674  }
675 
676  [[nodiscard]] constexpr bool any() const noexcept {
677  for (auto& v : a) {
678  if (v > 0) {
679  return true;
680  }
681  }
682  return false;
683  }
684 
685  [[nodiscard]] constexpr bool none() const noexcept { return !any(); }
686 
687  [[nodiscard]] constexpr std::size_t count() const noexcept {
688  std::size_t c = 0;
689  for (auto& v : a) {
690  c += detail::popcount(v);
691  }
692  return c;
693  }
694 
695  [[nodiscard]] constexpr std::size_t size() const noexcept { return enum_count<E>(); }
696 
697  [[nodiscard]] constexpr std::size_t max_size() const noexcept { return enum_count<E>(); }
698 
699  constexpr bitset& operator&=(const bitset& other) noexcept {
700  for (std::size_t i = 0; i < base_type_count; ++i) {
701  a[i] &= other.a[i];
702  }
703  return *this;
704  }
705 
706  constexpr bitset& operator|=(const bitset& other) noexcept {
707  for (std::size_t i = 0; i < base_type_count; ++i) {
708  a[i] |= other.a[i];
709  }
710  return *this;
711  }
712 
713  constexpr bitset& operator^=(const bitset& other) noexcept {
714  for (std::size_t i = 0; i < base_type_count; ++i) {
715  a[i] ^= other.a[i];
716  }
717  return *this;
718  }
719 
720  [[nodiscard]] constexpr bitset operator~() const noexcept {
721  bitset res;
722  for (std::size_t i = 0; i < base_type_count - (not_interested > 0); ++i) {
723  res.a[i] = ~a[i];
724  }
725 
726  if constexpr (not_interested > 0) {
727  res.a[base_type_count - 1] = ~a[base_type_count - 1] & last_value_max;
728  }
729  return res;
730  }
731 
732  constexpr bitset& set() noexcept {
733  for (std::size_t i = 0; i < base_type_count - (not_interested > 0); ++i) {
734  a[i] = ~base_type{0};
735  }
736 
737  if constexpr (not_interested > 0) {
739  }
740  return *this;
741  }
742 
743  constexpr bitset& set(E pos, bool value = true) {
744  if (auto i = index_type::at(pos)) {
745  reference{this, *i} = value;
746  return *this;
747  }
748  MAGIC_ENUM_THROW(std::out_of_range("magic_enum::containers::bitset::set: Unrecognized position"));
749  }
750 
751  constexpr bitset& reset() noexcept { return *this = bitset{}; }
752 
753  constexpr bitset& reset(E pos) {
754  if (auto i = index_type::at(pos)) {
755  reference{this, *i} = false;
756  return *this;
757  }
758  MAGIC_ENUM_THROW(std::out_of_range("magic_enum::containers::bitset::reset: Unrecognized position"));
759  }
760 
761  constexpr bitset& flip() noexcept { return *this = ~*this; }
762 
763  [[nodiscard]] friend constexpr bitset operator&(const bitset& lhs, const bitset& rhs) noexcept {
764  bitset cp = lhs;
765  cp &= rhs;
766  return cp;
767  }
768 
769  [[nodiscard]] friend constexpr bitset operator|(const bitset& lhs, const bitset& rhs) noexcept {
770  bitset cp = lhs;
771  cp |= rhs;
772  return cp;
773  }
774 
775  [[nodiscard]] friend constexpr bitset operator^(const bitset& lhs, const bitset& rhs) noexcept {
776  bitset cp = lhs;
777  cp ^= rhs;
778  return cp;
779  }
780 
781  template <typename V = E>
782  [[nodiscard]] constexpr explicit operator std::enable_if_t<magic_enum::detail::subtype_v<V> == magic_enum::detail::enum_subtype::flags, E>() const {
783  E res{};
784  for (const auto& e : enum_values<E>()) {
785  if (test(e)) {
786  res |= e;
787  }
788  }
789  return res;
790  }
791 
792  [[nodiscard]] string to_string(char_type sep = static_cast<char_type>('|')) const {
793  string name;
794 
795  for (const auto& e : enum_values<E>()) {
796  if (test(e)) {
797  if (!name.empty()) {
798  name.append(1, sep);
799  }
800  auto n = enum_name(e);
801  name.append(n.data(), n.size());
802  }
803  }
804  return name;
805  }
806 
807  [[nodiscard]] string to_string(detail::raw_access_t, char_type zero = static_cast<char_type>('0'), char_type one = static_cast<char_type>('1')) const {
808  string name;
809  name.reserve(size());
810  for (std::size_t i = 0; i < size(); ++i) {
811  name.append(1, const_reference{this, i} ? one : zero);
812  }
813  return name;
814  }
815 
816  [[nodiscard]] constexpr unsigned long long to_ullong(detail::raw_access_t raw) const { return to_<unsigned long long>(raw); }
817 
818  [[nodiscard]] constexpr unsigned long long to_ulong(detail::raw_access_t raw) const { return to_<unsigned long>(raw); }
819 
820  friend std::ostream& operator<<(std::ostream& o, const bitset& bs) { return o << bs.to_string(); }
821 
822  friend std::istream& operator>>(std::istream& i, bitset& bs) {
823  string s;
824  if (i >> s; !s.empty()) {
825  bs = bitset(string_view{s});
826  }
827  return i;
828  }
829 
830  private:
832 };
833 
834 template <typename V, int = 0>
835 explicit bitset(V starter) -> bitset<V>;
836 
838 // SET //
840 template <typename E, typename Cmp = std::less<E>>
841 class set {
843  struct Getter {
844  constexpr const E& operator()(const set*, const E* p) const noexcept { return *p; }
845  };
846  struct Predicate {
847  constexpr bool operator()(const set* h, const E* e) const noexcept { return h->a[*e]; }
848  };
849 
850  public:
852  using key_type = E;
853  using value_type = E;
854  using size_type = std::size_t;
855  using difference_type = std::ptrdiff_t;
856  using key_compare = Cmp;
857  using value_compare = Cmp;
859  using const_reference = const value_type&;
860  using pointer = value_type*;
861  using const_pointer = const value_type*;
864  using reverse_iterator = std::reverse_iterator<iterator>;
865  using const_reverse_iterator = std::reverse_iterator<const_iterator>;
866 
867  constexpr set() noexcept = default;
868 
869  template <typename InputIt>
870  constexpr set(InputIt first, InputIt last) {
871  while (first != last) {
872  insert(*first++);
873  }
874  }
875 
876  constexpr set(std::initializer_list<E> ilist) {
877  for (auto e : ilist) {
878  insert(e);
879  }
880  }
881  template <typename V, std::enable_if_t<std::is_same_v<V, E> && magic_enum::detail::subtype_v<V> == magic_enum::detail::enum_subtype::flags, int> = 0>
882  constexpr explicit set(V starter) {
883  auto u = enum_underlying(starter);
884  for (E v : enum_values<E>()) {
885  if ((enum_underlying(v) & u) != 0) {
886  insert(v);
887  }
888  }
889  }
890 
891  constexpr set(const set&) noexcept = default;
892  constexpr set(set&&) noexcept = default;
893 
894  constexpr set& operator=(const set&) noexcept = default;
895  constexpr set& operator=(set&&) noexcept = default;
896  constexpr set& operator=(std::initializer_list<E> ilist) {
897  for (auto e : ilist) {
898  insert(e);
899  }
900  }
901 
902  constexpr const_iterator begin() const noexcept {
904  }
905 
906  constexpr const_iterator end() const noexcept {
908  }
909 
910  constexpr const_iterator cbegin() const noexcept { return begin(); }
911 
912  constexpr const_iterator cend() const noexcept { return end(); }
913 
914  constexpr const_reverse_iterator rbegin() const noexcept { return {end()}; }
915 
916  constexpr const_reverse_iterator rend() const noexcept { return {begin()}; }
917 
918  constexpr const_reverse_iterator crbegin() const noexcept { return rbegin(); }
919 
920  constexpr const_reverse_iterator crend() const noexcept { return rend(); }
921 
922  [[nodiscard]] constexpr bool empty() const noexcept { return s == 0; }
923 
924  [[nodiscard]] constexpr size_type size() const noexcept { return s; }
925 
926  [[nodiscard]] constexpr size_type max_size() const noexcept { return a.max_size(); }
927 
928  constexpr void clear() noexcept {
929  a.reset();
930  s = 0;
931  }
932 
933  constexpr std::pair<iterator, bool> insert(const value_type& value) noexcept {
934  if (auto i = index_type::at(value)) {
935  typename container_type::reference ref = a[value];
936  bool r = !ref;
937  if (r) {
938  ref = true;
939  ++s;
940  }
941 
942  return {iterator{this, index_type::begin(), index_type::end(), index_type::it(*i)}, r};
943  }
944  return {end(), false};
945  }
946 
947  constexpr std::pair<iterator, bool> insert(value_type&& value) noexcept { return insert(value); }
948 
949  constexpr iterator insert(const_iterator, const value_type& value) noexcept { return insert(value).first; }
950 
951  constexpr iterator insert(const_iterator hint, value_type&& value) noexcept { return insert(hint, value); }
952 
953  template <typename InputIt>
954  constexpr void insert(InputIt first, InputIt last) noexcept {
955  while (first != last) {
956  insert(*first++);
957  }
958  }
959 
960  constexpr void insert(std::initializer_list<value_type> ilist) noexcept {
961  for (auto v : ilist) {
962  insert(v);
963  }
964  }
965 
966  template <typename... Args>
967  constexpr std::pair<iterator, bool> emplace(Args&&... args) noexcept {
968  return insert({std::forward<Args>(args)...});
969  }
970 
971  template <typename... Args>
972  constexpr iterator emplace_hint(const_iterator, Args&&... args) noexcept {
973  return emplace(std::forward<Args>(args)...).first;
974  }
975 
976  constexpr iterator erase(const_iterator pos) noexcept {
977  erase(*pos++);
978  return pos;
979  }
980 
981  constexpr iterator erase(const_iterator first, const_iterator last) noexcept {
982  while ((first = erase(first)) != last) {
983  }
984  return first;
985  }
986 
987  constexpr size_type erase(const key_type& key) noexcept {
988  typename container_type::reference ref = a[key];
989  bool res = ref;
990  if (res) {
991  --s;
992  }
993  ref = false;
994  return res;
995  }
996 
997  template <typename K, typename KC = key_compare>
998  constexpr std::enable_if_t<detail::is_transparent_v<KC>, size_type> erase(K&& x) noexcept {
999  size_type c = 0;
1000  for (auto [first, last] = detail::equal_range(index_type::begin(), index_type::end(), x, key_compare{}); first != last;) {
1001  c += erase(*first++);
1002  }
1003  return c;
1004  }
1005 
1006  void swap(set& other) noexcept {
1007  set cp = *this;
1008  *this = other;
1009  other = cp;
1010  }
1011 
1012  [[nodiscard]] constexpr size_type count(const key_type& key) const noexcept { return index_type::at(key) && a[key]; }
1013 
1014  template <typename K, typename KC = key_compare>
1015  [[nodiscard]] constexpr std::enable_if_t<detail::is_transparent_v<KC>, size_type> count(const K& x) const {
1016  size_type c = 0;
1017  for (auto [first, last] = detail::equal_range(index_type::begin(), index_type::end(), x, key_compare{}); first != last; ++first) {
1018  c += count(*first);
1019  }
1020  return c;
1021  }
1022 
1023  [[nodiscard]] constexpr const_iterator find(const key_type& key) const noexcept {
1024  if (auto i = index_type::at(key); i && a.test(key)) {
1026  }
1027  return end();
1028  }
1029 
1030  template <typename K, typename KC = key_compare>
1031  [[nodiscard]] constexpr std::enable_if_t<detail::is_transparent_v<KC>, const_iterator> find(const K& x) const {
1032  for (auto [first, last] = detail::equal_range(index_type::begin(), index_type::end(), x, key_compare{}); first != last; ++first) {
1033  if (a.test(*first)) {
1034  return find(*first);
1035  }
1036  }
1037  return end();
1038  }
1039 
1040  [[nodiscard]] constexpr bool contains(const key_type& key) const noexcept { return count(key); }
1041 
1042  template <typename K, typename KC = key_compare>
1043  [[nodiscard]] constexpr std::enable_if_t<detail::is_transparent_v<KC>, bool> contains(const K& x) const noexcept {
1044  return count(x) > 0;
1045  }
1046 
1047  [[nodiscard]] constexpr std::pair<const_iterator, const_iterator> equal_range(const key_type& key) const noexcept { return {lower_bound(key), upper_bound(key)}; }
1048 
1049  template <typename K, typename KC = key_compare>
1050  [[nodiscard]] constexpr std::enable_if_t<detail::is_transparent_v<KC>, std::pair<const_iterator, const_iterator>> equal_range(const K& x) const noexcept {
1051  return {lower_bound(x), upper_bound(x)};
1052  }
1053 
1054  [[nodiscard]] constexpr const_iterator lower_bound(const key_type& key) const noexcept {
1055  if (auto i = index_type::at(key)) {
1057  return a.test(key) ? it : std::next(it);
1058  }
1059  return end();
1060  }
1061 
1062  template <typename K, typename KC = key_compare>
1063  [[nodiscard]] constexpr std::enable_if_t<detail::is_transparent_v<KC>, const_iterator> lower_bound(const K& x) const noexcept {
1064  auto [first, last] = detail::equal_range(index_type::begin(), index_type::end(), x, key_compare{});
1065  return first != last ? lower_bound(*first) : end();
1066  }
1067 
1068  [[nodiscard]] constexpr const_iterator upper_bound(const key_type& key) const noexcept {
1069  if (auto i = index_type::at(key)) {
1070  return std::next(const_iterator{this, index_type::begin(), index_type::end(), index_type::it(*i)});
1071  }
1072  return end();
1073  }
1074 
1075  template <typename K, typename KC = key_compare>
1076  [[nodiscard]] constexpr std::enable_if_t<detail::is_transparent_v<KC>, const_iterator> upper_bound(const K& x) const noexcept {
1077  auto [first, last] = detail::equal_range(index_type::begin(), index_type::end(), x, key_compare{});
1078  return first != last ? upper_bound(*std::prev(last)) : end();
1079  }
1080 
1081  [[nodiscard]] constexpr key_compare key_comp() const { return {}; }
1082 
1083  [[nodiscard]] constexpr value_compare value_comp() const { return {}; }
1084 
1085  [[nodiscard]] constexpr friend bool operator==(const set& lhs, const set& rhs) noexcept { return lhs.a == rhs.a; }
1086 
1087  [[nodiscard]] constexpr friend bool operator!=(const set& lhs, const set& rhs) noexcept { return lhs.a != rhs.a; }
1088 
1089  [[nodiscard]] constexpr friend bool operator<(const set& lhs, const set& rhs) noexcept {
1090  if (lhs.s < rhs.s) {
1091  return true;
1092  }
1093  if (rhs.s < lhs.s) {
1094  return false;
1095  }
1096 
1097  for (auto it = index_type::begin(); it != index_type::end(); ++it) {
1098  if (auto c = rhs.contains(*it); c != lhs.contains(*it)) {
1099  return c;
1100  }
1101  }
1102  return false;
1103  }
1104 
1105  [[nodiscard]] constexpr friend bool operator<=(const set& lhs, const set& rhs) noexcept { return !(rhs < lhs); }
1106 
1107  [[nodiscard]] constexpr friend bool operator>(const set& lhs, const set& rhs) noexcept { return rhs < lhs; }
1108 
1109  [[nodiscard]] constexpr friend bool operator>=(const set& lhs, const set& rhs) noexcept { return !(lhs < rhs); }
1110 
1111  template <typename Pred>
1112  size_type erase_if(Pred pred) {
1113  auto old_size = size();
1114  for (auto i = begin(), last = end(); i != last;) {
1115  if (pred(*i)) {
1116  i = erase(i);
1117  } else {
1118  ++i;
1119  }
1120  }
1121  return old_size - size();
1122  }
1123 
1124  private:
1126  std::size_t s = 0;
1127 };
1128 
1129 template <typename V, int = 0>
1130 explicit set(V starter) -> set<V>;
1131 
1132 template <auto I, typename E, typename V, typename Index>
1133 constexpr std::enable_if_t<(std::is_integral_v<decltype(I)> && I < enum_count<E>()), V&> get(array<E, V, Index>& a) noexcept {
1134  return a.a[I];
1135 }
1136 
1137 template <auto I, typename E, typename V, typename Index>
1138 constexpr std::enable_if_t<(std::is_integral_v<decltype(I)> && I < enum_count<E>()), V&&> get(array<E, V, Index>&& a) noexcept {
1139  return std::move(a.a[I]);
1140 }
1141 
1142 template <auto I, typename E, typename V, typename Index>
1143 constexpr std::enable_if_t<(std::is_integral_v<decltype(I)> && I < enum_count<E>()), const V&> get(const array<E, V, Index>& a) noexcept {
1144  return a.a[I];
1145 }
1146 
1147 template <auto I, typename E, typename V, typename Index>
1148 constexpr std::enable_if_t<(std::is_integral_v<decltype(I)> && I < enum_count<E>()), const V&&> get(const array<E, V, Index>&& a) noexcept {
1149  return std::move(a.a[I]);
1150 }
1151 
1152 template <auto Enum, typename E, typename V, typename Index>
1153 constexpr std::enable_if_t<std::is_same_v<decltype(Enum), E> && enum_contains(Enum), V&> get(array<E, V, Index>& a) {
1154  return a[Enum];
1155 }
1156 
1157 template <auto Enum, typename E, typename V, typename Index>
1158 constexpr std::enable_if_t<std::is_same_v<decltype(Enum), E> && enum_contains(Enum), V&&> get(array<E, V, Index>&& a) {
1159  return std::move(a[Enum]);
1160 }
1161 
1162 template <auto Enum, typename E, typename V, typename Index>
1163 constexpr std::enable_if_t<std::is_same_v<decltype(Enum), E> && enum_contains(Enum), const V&> get(const array<E, V, Index>& a) {
1164  return a[Enum];
1165 }
1166 
1167 template <auto Enum, typename E, typename V, typename Index>
1168 constexpr std::enable_if_t<std::is_same_v<decltype(Enum), E> && enum_contains(Enum), const V&&> get(const array<E, V, Index>&& a) {
1169  return std::move(a[Enum]);
1170 }
1171 
1172 } // namespace magic_enum::containers
1173 
1174 #endif // NEARGYE_MAGIC_ENUM_CONTAINERS_HPP
magic_enum::containers::bitset::reference_impl::reference_impl
constexpr reference_impl(parent_t p, std::pair< std::size_t, base_type > i) noexcept
Definition: magic_enum_containers.hpp:510
magic_enum::containers::set::swap
void swap(set &other) noexcept
Definition: magic_enum_containers.hpp:1006
magic_enum::containers::array::fill
constexpr void fill(const V &value)
Definition: magic_enum_containers.hpp:421
magic_enum::Enum
detail::enum_concept< T > Enum
Definition: magic_enum.hpp:1144
magic_enum::containers::detail::FilteredIterator::pointer
value_type * pointer
Definition: magic_enum_containers.hpp:258
magic_enum::containers::bitset::set
constexpr bitset & set() noexcept
Definition: magic_enum_containers.hpp:732
magic_enum::containers::array::rend
constexpr iterator rend() noexcept
Definition: magic_enum_containers.hpp:409
magic_enum::containers::set::s
std::size_t s
Definition: magic_enum_containers.hpp:1126
magic_enum::containers::bitset::reference_impl::num_index
std::size_t num_index
Definition: magic_enum_containers.hpp:505
magic_enum::containers::set::lower_bound
constexpr const_iterator lower_bound(const key_type &key) const noexcept
Definition: magic_enum_containers.hpp:1054
magic_enum::containers::set::crbegin
constexpr const_reverse_iterator crbegin() const noexcept
Definition: magic_enum_containers.hpp:918
magic_enum::containers::bitset::last_value_max
static constexpr base_type last_value_max
Definition: magic_enum_containers.hpp:498
magic_enum::containers::set::set
constexpr set(std::initializer_list< E > ilist)
Definition: magic_enum_containers.hpp:876
magic_enum::containers::bitset
Definition: magic_enum_containers.hpp:485
magic_enum::containers::bitset::reference_impl::operator~
constexpr bool operator~() const noexcept
Definition: magic_enum_containers.hpp:532
magic_enum::containers::array::const_pointer
typename container_type::const_pointer const_pointer
Definition: magic_enum_containers.hpp:349
magic_enum::containers::set::emplace_hint
constexpr iterator emplace_hint(const_iterator, Args &&... args) noexcept
Definition: magic_enum_containers.hpp:972
magic_enum::containers::detail::FilteredIterator::predicate
Predicate predicate
Definition: magic_enum_containers.hpp:253
magic_enum::containers::bitset::bitset
constexpr bitset(std::initializer_list< E > starters)
Definition: magic_enum_containers.hpp:595
magic_enum::containers::detail::indexing< E, Cmp, std::enable_if_t< std::is_enum_v< std::decay_t< E > > &&(std::is_same_v< Cmp, std::less< E >>||std::is_same_v< Cmp, std::less<>>)> >::at
static constexpr optional< std::size_t > at(E val) noexcept
Definition: magic_enum_containers.hpp:190
magic_enum::containers::array::begin
constexpr const_iterator begin() const noexcept
Definition: magic_enum_containers.hpp:393
magic_enum::containers::set::equal_range
constexpr std::pair< const_iterator, const_iterator > equal_range(const key_type &key) const noexcept
Definition: magic_enum_containers.hpp:1047
magic_enum::detail::enum_subtype::flags
@ flags
magic_enum::containers::detail::FilteredIterator::iterator_category
std::bidirectional_iterator_tag iterator_category
Definition: magic_enum_containers.hpp:255
magic_enum::containers::set::value_compare
Cmp value_compare
Definition: magic_enum_containers.hpp:857
magic_enum::containers::set::equal_range
constexpr std::enable_if_t< detail::is_transparent_v< KC >, std::pair< const_iterator, const_iterator > > equal_range(const K &x) const noexcept
Definition: magic_enum_containers.hpp:1050
magic_enum::containers::set
set(V starter) -> set< V >
magic_enum::containers::set::operator>
constexpr friend bool operator>(const set &lhs, const set &rhs) noexcept
Definition: magic_enum_containers.hpp:1107
magic_enum::char_type
string_view::value_type char_type
Definition: magic_enum.hpp:149
magic_enum::containers::set::difference_type
std::ptrdiff_t difference_type
Definition: magic_enum_containers.hpp:855
s1
@ s1
Definition: test.cpp:452
magic_enum::containers::bitset::bitset
constexpr bitset(V starter)
Definition: magic_enum_containers.hpp:607
magic_enum::containers::detail::FilteredIterator::FilteredIterator
constexpr FilteredIterator() noexcept=default
magic_enum::containers::detail::lower_bound
constexpr ForwardIt lower_bound(ForwardIt first, ForwardIt last, E &&e, Cmp &&comp={})
Definition: magic_enum_containers.hpp:105
magic_enum.hpp
magic_enum::containers::set::find
constexpr std::enable_if_t< detail::is_transparent_v< KC >, const_iterator > find(const K &x) const
Definition: magic_enum_containers.hpp:1031
magic_enum::containers::array::crend
constexpr const_iterator crend() const noexcept
Definition: magic_enum_containers.hpp:413
magic_enum::containers::array::back
constexpr reference back() noexcept
Definition: magic_enum_containers.hpp:383
magic_enum::detail::is_enum_v
constexpr bool is_enum_v
Definition: magic_enum.hpp:418
magic_enum::containers::array::operator==
constexpr friend bool operator==(const array &a1, const array &a2)
Definition: magic_enum_containers.hpp:435
magic_enum::containers::set::key_compare
Cmp key_compare
Definition: magic_enum_containers.hpp:856
magic_enum::containers::bitset::to_string
string to_string(char_type sep=static_cast< char_type >('|')) const
Definition: magic_enum_containers.hpp:792
magic_enum::containers::array::cbegin
constexpr const_iterator cbegin() const noexcept
Definition: magic_enum_containers.hpp:395
magic_enum::containers::detail::FilteredIterator::operator--
constexpr FilteredIterator & operator--()
Definition: magic_enum_containers.hpp:295
magic_enum::containers::set::upper_bound
constexpr std::enable_if_t< detail::is_transparent_v< KC >, const_iterator > upper_bound(const K &x) const noexcept
Definition: magic_enum_containers.hpp:1076
magic_enum::containers::bitset::reset
constexpr bitset & reset(E pos)
Definition: magic_enum_containers.hpp:753
magic_enum::detail::enable_if_t
typename enable_if_enum< std::is_enum_v< D > &&std::is_invocable_r_v< bool, BinaryPredicate, char_type, char_type >, R >::type enable_if_t
Definition: magic_enum.hpp:904
magic_enum::containers::set::operator<
constexpr friend bool operator<(const set &lhs, const set &rhs) noexcept
Definition: magic_enum_containers.hpp:1089
magic_enum::containers::array::back
constexpr const_reference back() const noexcept
Definition: magic_enum_containers.hpp:385
magic_enum::containers::array::const_reverse_iterator
typename container_type::const_reverse_iterator const_reverse_iterator
Definition: magic_enum_containers.hpp:353
magic_enum::containers::bitset::max_size
constexpr std::size_t max_size() const noexcept
Definition: magic_enum_containers.hpp:697
magic_enum::containers::set::count
constexpr size_type count(const key_type &key) const noexcept
Definition: magic_enum_containers.hpp:1012
magic_enum::containers::set::a
container_type a
Definition: magic_enum_containers.hpp:1125
magic_enum::containers::set::value_type
E value_type
Definition: magic_enum_containers.hpp:853
magic_enum::containers::detail::indexing::begin
static constexpr const E * begin() noexcept
Definition: magic_enum_containers.hpp:165
magic_enum::containers::detail::to_array_impl
constexpr array< E, std::remove_cv_t< T > > to_array_impl(T(&a)[N], std::index_sequence< I... >)
Definition: magic_enum_containers.hpp:453
magic_enum::containers::array::empty
constexpr bool empty() const noexcept
Definition: magic_enum_containers.hpp:415
magic_enum::containers::array::operator>
constexpr friend bool operator>(const array &a1, const array &a2)
Definition: magic_enum_containers.hpp:443
magic_enum::containers::detail::name_sort_impl< void, Cmp >::FullCmp< C, std::enable_if_t<!std::is_invocable_v< C, string_view, string_view > &&std::is_invocable_v< C, char_type, char_type > > >::operator()
constexpr bool operator()(string_view s1, string_view s2) const noexcept
Definition: magic_enum_containers.hpp:217
magic_enum::containers::detail::indexing::indices
static constexpr auto indices
Definition: magic_enum_containers.hpp:162
magic_enum::containers::bitset::all
constexpr bool all() const noexcept
Definition: magic_enum_containers.hpp:659
magic_enum::containers::detail::equal_range
constexpr auto equal_range(BidirIt begin, BidirIt end, E &&e, Cmp &&comp={})
Definition: magic_enum_containers.hpp:121
magic_enum::containers::bitset::operator&
constexpr friend bitset operator&(const bitset &lhs, const bitset &rhs) noexcept
Definition: magic_enum_containers.hpp:763
magic_enum::containers::set::rbegin
constexpr const_reverse_iterator rbegin() const noexcept
Definition: magic_enum_containers.hpp:914
magic_enum::containers::set::empty
constexpr bool empty() const noexcept
Definition: magic_enum_containers.hpp:922
MAGIC_ENUM_THROW
#define MAGIC_ENUM_THROW(...)
Definition: magic_enum_containers.hpp:47
magic_enum::containers::detail::popcount
constexpr std::size_t popcount(T x) noexcept
Definition: magic_enum_containers.hpp:95
magic_enum::containers::bitset::operator[]
constexpr reference operator[](E pos)
Definition: magic_enum_containers.hpp:647
magic_enum::containers::array::cend
constexpr const_iterator cend() const noexcept
Definition: magic_enum_containers.hpp:401
magic_enum::containers::set::Getter::operator()
constexpr const E & operator()(const set *, const E *p) const noexcept
Definition: magic_enum_containers.hpp:844
magic_enum::containers::set::operator<=
constexpr friend bool operator<=(const set &lhs, const set &rhs) noexcept
Definition: magic_enum_containers.hpp:1105
magic_enum::containers::set::rend
constexpr const_reverse_iterator rend() const noexcept
Definition: magic_enum_containers.hpp:916
magic_enum::containers::detail::FilteredIterator::FilteredIterator
constexpr FilteredIterator(Parent p, Iterator begin, Iterator end, Iterator curr, Getter get={}, Predicate pred={})
Definition: magic_enum_containers.hpp:271
magic_enum::detail::value
constexpr E value(std::size_t i) noexcept
Definition: magic_enum.hpp:679
magic_enum::containers::bitset::reference_impl::bit_index
base_type bit_index
Definition: magic_enum_containers.hpp:506
magic_enum::containers::bitset::bitset
constexpr bitset(detail::raw_access_t, const char_type *str, std::size_t n=~std::size_t{0}, char_type zero=static_cast< char_type >('0'), char_type one=static_cast< char_type >('1'))
Definition: magic_enum_containers.hpp:592
magic_enum::containers::set::contains
constexpr bool contains(const key_type &key) const noexcept
Definition: magic_enum_containers.hpp:1040
magic_enum::containers::bitset::to_string
string to_string(detail::raw_access_t, char_type zero=static_cast< char_type >('0'), char_type one=static_cast< char_type >('1')) const
Definition: magic_enum_containers.hpp:807
magic_enum::containers::bitset::bitset
constexpr bitset(detail::raw_access_t, string_view sv, string_view::size_type pos=0, string_view::size_type n=string_view::npos, char_type zero=static_cast< char_type >('0'), char_type one=static_cast< char_type >('1'))
Definition: magic_enum_containers.hpp:576
magic_enum::containers::bitset::operator<<
friend std::ostream & operator<<(std::ostream &o, const bitset &bs)
Definition: magic_enum_containers.hpp:820
magic_enum::containers::array
Definition: magic_enum_containers.hpp:335
magic_enum::containers::detail::indexing::get_indices
static constexpr auto get_indices() noexcept
Definition: magic_enum_containers.hpp:128
magic_enum::containers::detail::FilteredIterator::operator->
constexpr pointer operator->() const
Definition: magic_enum_containers.hpp:280
magic_enum::containers::set::pointer
value_type * pointer
Definition: magic_enum_containers.hpp:860
Catch::Matchers::Predicate
Generic::PredicateMatcher< T > Predicate(std::function< bool(T const &)> const &predicate, std::string const &description="")
Definition: catch.hpp:3519
magic_enum::containers::detail::indexing< E, Cmp, std::enable_if_t< std::is_enum_v< std::decay_t< E > > &&(std::is_same_v< Cmp, std::less< E >>||std::is_same_v< Cmp, std::less<>>)> >::it
static constexpr const E * it(std::size_t i) noexcept
Definition: magic_enum_containers.hpp:188
magic_enum::containers::array::begin
constexpr iterator begin() noexcept
Definition: magic_enum_containers.hpp:391
magic_enum::containers::raw_access
constexpr detail::raw_access_t raw_access
Definition: magic_enum_containers.hpp:479
magic_enum::containers::bitset::size
constexpr std::size_t size() const noexcept
Definition: magic_enum_containers.hpp:695
magic_enum::containers::bitset< E, index_type >::const_reference
reference_impl< const bitset * > const_reference
Definition: magic_enum_containers.hpp:559
magic_enum::containers::set::reference
value_type & reference
Definition: magic_enum_containers.hpp:858
magic_enum::containers::array::operator!=
constexpr friend bool operator!=(const array &a1, const array &a2)
Definition: magic_enum_containers.hpp:437
magic_enum::containers::bitset::reference_impl::operator=
constexpr reference_impl & operator=(const reference_impl &v) noexcept
Definition: magic_enum_containers.hpp:522
magic_enum::containers::bitset::bits_per_base
static constexpr std::size_t bits_per_base
Definition: magic_enum_containers.hpp:495
magic_enum::containers::array::reference
typename container_type::reference reference
Definition: magic_enum_containers.hpp:346
magic_enum::containers::array::operator<=
constexpr friend bool operator<=(const array &a1, const array &a2)
Definition: magic_enum_containers.hpp:441
magic_enum::containers::bitset::operator[]
constexpr bool operator[](E pos) const
Definition: magic_enum_containers.hpp:642
Numbers::one
@ one
magic_enum::containers::bitset::none
constexpr bool none() const noexcept
Definition: magic_enum_containers.hpp:685
magic_enum::containers::bitset::bitset
constexpr bitset(detail::raw_access_t, unsigned long long val)
Definition: magic_enum_containers.hpp:563
magic_enum::containers::array::operator>=
constexpr friend bool operator>=(const array &a1, const array &a2)
Definition: magic_enum_containers.hpp:445
magic_enum::containers::set::erase
constexpr std::enable_if_t< detail::is_transparent_v< KC >, size_type > erase(K &&x) noexcept
Definition: magic_enum_containers.hpp:998
magic_enum::containers::detail::raw_access_t
Definition: magic_enum_containers.hpp:244
magic_enum::containers::array::size
constexpr size_type size() const noexcept
Definition: magic_enum_containers.hpp:417
magic_enum::containers::set::count
constexpr std::enable_if_t< detail::is_transparent_v< KC >, size_type > count(const K &x) const
Definition: magic_enum_containers.hpp:1015
magic_enum::containers::bitset::test
constexpr bool test(E pos) const
Definition: magic_enum_containers.hpp:652
magic_enum::containers::array::data
constexpr const_pointer data() const noexcept
Definition: magic_enum_containers.hpp:389
magic_enum::containers::bitset::operator!=
constexpr friend bool operator!=(const bitset &lhs, const bitset &rhs) noexcept
Definition: magic_enum_containers.hpp:640
magic_enum::containers::set::cbegin
constexpr const_iterator cbegin() const noexcept
Definition: magic_enum_containers.hpp:910
magic_enum::containers::bitset::reset
constexpr bitset & reset() noexcept
Definition: magic_enum_containers.hpp:751
magic_enum::containers::set::erase
constexpr size_type erase(const key_type &key) noexcept
Definition: magic_enum_containers.hpp:987
magic_enum::containers::set::set
constexpr set() noexcept=default
magic_enum::containers::detail::equal
constexpr bool equal(T1 &&t1, T2 &&t2, Eq &&eq={})
Definition: magic_enum_containers.hpp:61
magic_enum::containers::set::const_reference
const value_type & const_reference
Definition: magic_enum_containers.hpp:859
magic_enum::containers::array::difference_type
typename container_type::difference_type difference_type
Definition: magic_enum_containers.hpp:345
magic_enum::containers::set::insert
constexpr iterator insert(const_iterator hint, value_type &&value) noexcept
Definition: magic_enum_containers.hpp:951
magic_enum::containers::array::const_iterator
typename container_type::const_iterator const_iterator
Definition: magic_enum_containers.hpp:351
magic_enum::containers
Definition: magic_enum_containers.hpp:50
magic_enum::containers::detail::indexing< void, Cmp, void >::is_transparent
std::true_type is_transparent
Definition: magic_enum_containers.hpp:195
magic_enum::containers::array::iterator
typename container_type::iterator iterator
Definition: magic_enum_containers.hpp:350
magic_enum::containers::bitset::to_
constexpr T to_(detail::raw_access_t) const
Definition: magic_enum_containers.hpp:541
magic_enum::enum_contains
constexpr auto enum_contains(E value) noexcept -> detail::enable_if_t< E, bool >
Definition: magic_enum.hpp:1396
magic_enum::detail::values
constexpr auto values() noexcept
Definition: magic_enum.hpp:757
magic_enum::containers::bitset::reference_impl
Definition: magic_enum_containers.hpp:501
magic_enum::containers::detail::indexing< void, Cmp, void >::at
static constexpr optional< std::size_t > at(E val) noexcept
Definition: magic_enum_containers.hpp:198
magic_enum::containers::set::max_size
constexpr size_type max_size() const noexcept
Definition: magic_enum_containers.hpp:926
magic_enum::containers::set::cend
constexpr const_iterator cend() const noexcept
Definition: magic_enum_containers.hpp:912
magic_enum::containers::set::Predicate
Definition: magic_enum_containers.hpp:846
magic_enum::containers::detail::FilteredIterator::first
Iterator first
Definition: magic_enum_containers.hpp:249
magic_enum::containers::bitset::operator|=
constexpr bitset & operator|=(const bitset &other) noexcept
Definition: magic_enum_containers.hpp:706
magic_enum::containers::bitset::operator~
constexpr bitset operator~() const noexcept
Definition: magic_enum_containers.hpp:720
magic_enum::containers::detail::FilteredIterator::operator++
constexpr FilteredIterator operator++(int)
Definition: magic_enum_containers.hpp:289
magic_enum::containers::bitset< E, index_type >::reference
reference_impl<> reference
Definition: magic_enum_containers.hpp:558
magic_enum::enum_underlying
constexpr auto enum_underlying(E value) noexcept -> detail::enable_if_t< E, underlying_type_t< E >>
Definition: magic_enum.hpp:1231
magic_enum::containers::set::erase_if
size_type erase_if(Pred pred)
Definition: magic_enum_containers.hpp:1112
magic_enum::containers::array::swap
constexpr void swap(array &other) noexcept(std::is_nothrow_swappable_v< V >)
Definition: magic_enum_containers.hpp:427
magic_enum::containers::detail::indexing::end
static constexpr const E * end() noexcept
Definition: magic_enum_containers.hpp:167
magic_enum::containers::detail::name_sort_impl::operator()
constexpr bool operator()(E e1, E e2) const noexcept
Definition: magic_enum_containers.hpp:205
magic_enum::containers::detail::FilteredIterator::difference_type
std::ptrdiff_t difference_type
Definition: magic_enum_containers.hpp:257
magic_enum::containers::bitset::operator^=
constexpr bitset & operator^=(const bitset &other) noexcept
Definition: magic_enum_containers.hpp:713
magic_enum::containers::bitset::to_ulong
constexpr unsigned long long to_ulong(detail::raw_access_t raw) const
Definition: magic_enum_containers.hpp:818
magic_enum::containers::detail::indexing
Definition: magic_enum_containers.hpp:127
magic_enum::enum_index
constexpr auto enum_index(E value) noexcept -> detail::enable_if_t< E, optional< std::size_t >>
Definition: magic_enum.hpp:1238
magic_enum::containers::set::upper_bound
constexpr const_iterator upper_bound(const key_type &key) const noexcept
Definition: magic_enum_containers.hpp:1068
magic_enum::containers::array::operator[]
constexpr const_reference operator[](E pos) const
Definition: magic_enum_containers.hpp:374
magic_enum::containers::bitset::operator==
constexpr friend bool operator==(const bitset &lhs, const bitset &rhs) noexcept
Definition: magic_enum_containers.hpp:638
magic_enum::containers::bitset::operator|
constexpr friend bitset operator|(const bitset &lhs, const bitset &rhs) noexcept
Definition: magic_enum_containers.hpp:769
magic_enum::containers::set::contains
constexpr std::enable_if_t< detail::is_transparent_v< KC >, bool > contains(const K &x) const noexcept
Definition: magic_enum_containers.hpp:1043
magic_enum::containers::bitset::base_type
std::conditional_t< enum_count< E >()<=8, std::uint_least8_t, std::conditional_t< enum_count< E >()<=16, std::uint_least16_t, std::conditional_t< enum_count< E >()<=32, std::uint_least32_t, std::uint_least64_t > >> base_type
Definition: magic_enum_containers.hpp:493
magic_enum::containers::set::operator==
constexpr friend bool operator==(const set &lhs, const set &rhs) noexcept
Definition: magic_enum_containers.hpp:1085
magic_enum::containers::bitset::base_type_count
static constexpr std::size_t base_type_count
Definition: magic_enum_containers.hpp:496
MAGIC_ENUM_ASSERT
#define MAGIC_ENUM_ASSERT(...)
Definition: magic_enum.hpp:69
magic_enum::containers::set::Predicate::operator()
constexpr bool operator()(const set *h, const E *e) const noexcept
Definition: magic_enum_containers.hpp:847
magic_enum::containers::bitset::bitset
constexpr bitset(string_view sv, Cmp &&cmp={}, char_type sep=static_cast< char_type >('|'))
Definition: magic_enum_containers.hpp:621
magic_enum::containers::array::rend
constexpr const_iterator rend() const noexcept
Definition: magic_enum_containers.hpp:411
magic_enum::containers::set
Definition: magic_enum_containers.hpp:841
magic_enum::containers::bitset::operator^
constexpr friend bitset operator^(const bitset &lhs, const bitset &rhs) noexcept
Definition: magic_enum_containers.hpp:775
magic_enum::detail::n
constexpr auto n() noexcept
Definition: magic_enum.hpp:421
magic_enum::containers::set::emplace
constexpr std::pair< iterator, bool > emplace(Args &&... args) noexcept
Definition: magic_enum_containers.hpp:967
magic_enum::containers::array::rbegin
constexpr iterator rbegin() noexcept
Definition: magic_enum_containers.hpp:403
magic_enum::containers::set::crend
constexpr const_reverse_iterator crend() const noexcept
Definition: magic_enum_containers.hpp:920
magic_enum::containers::bitset::operator&=
constexpr bitset & operator&=(const bitset &other) noexcept
Definition: magic_enum_containers.hpp:699
magic_enum::containers::make_array
constexpr std::enable_if_t<(enum_count< E >)==sizeof...(Ts)), array< E, std::remove_cv_t< std::common_type_t< Ts... > > > > make_array(Ts &&... ts)
Definition: magic_enum_containers.hpp:475
magic_enum::containers::set::clear
constexpr void clear() noexcept
Definition: magic_enum_containers.hpp:928
magic_enum::containers::array::a
container_type a
Definition: magic_enum_containers.hpp:447
magic_enum::containers::bitset::reference_impl::flip
constexpr reference_impl & flip() noexcept
Definition: magic_enum_containers.hpp:534
magic_enum::containers::set::key_type
E key_type
Definition: magic_enum_containers.hpp:852
magic_enum::containers::detail::FilteredIterator::operator!=
constexpr friend bool operator!=(const FilteredIterator &lhs, const FilteredIterator &rhs)
Definition: magic_enum_containers.hpp:310
magic_enum::containers::detail::FilteredIterator::operator*
constexpr reference operator*() const
Definition: magic_enum_containers.hpp:278
magic_enum::containers::bitset::count
constexpr std::size_t count() const noexcept
Definition: magic_enum_containers.hpp:687
magic_enum::containers::array::value_type
typename container_type::value_type value_type
Definition: magic_enum_containers.hpp:343
magic_enum::containers::detail::FilteredIterator::reference
value_type & reference
Definition: magic_enum_containers.hpp:259
magic_enum::containers::bitset::flip
constexpr bitset & flip() noexcept
Definition: magic_enum_containers.hpp:761
magic_enum::containers::array::reverse_iterator
typename container_type::reverse_iterator reverse_iterator
Definition: magic_enum_containers.hpp:352
magic_enum::containers::detail::name_sort_impl
Definition: magic_enum_containers.hpp:204
magic_enum::containers::array::operator[]
constexpr reference operator[](E pos)
Definition: magic_enum_containers.hpp:369
magic_enum::containers::set::key_comp
constexpr key_compare key_comp() const
Definition: magic_enum_containers.hpp:1081
magic_enum::containers::set::insert
constexpr std::pair< iterator, bool > insert(const value_type &value) noexcept
Definition: magic_enum_containers.hpp:933
magic_enum::containers::detail::name_sort_impl< void, Cmp >::is_transparent
std::true_type is_transparent
Definition: magic_enum_containers.hpp:210
magic_enum::containers::set::operator>=
constexpr friend bool operator>=(const set &lhs, const set &rhs) noexcept
Definition: magic_enum_containers.hpp:1109
magic_enum::containers::detail::indexing< E, Cmp, std::enable_if_t< std::is_enum_v< std::decay_t< E > > &&(std::is_same_v< Cmp, std::less< E >>||std::is_same_v< Cmp, std::less<>>)> >::end
static constexpr const E * end() noexcept
Definition: magic_enum_containers.hpp:186
magic_enum::containers::set::insert
constexpr std::pair< iterator, bool > insert(value_type &&value) noexcept
Definition: magic_enum_containers.hpp:947
magic_enum::containers::detail::FilteredIterator::parent
Parent parent
Definition: magic_enum_containers.hpp:248
magic_enum::containers::bitset< E, index_type >::container_type
std::array< base_type, base_type_count > container_type
Definition: magic_enum_containers.hpp:557
magic_enum::containers::bitset::a
container_type a
Definition: magic_enum_containers.hpp:831
magic_enum::containers::detail::FilteredIterator::operator==
constexpr friend bool operator==(const FilteredIterator &lhs, const FilteredIterator &rhs)
Definition: magic_enum_containers.hpp:308
magic_enum::containers::set::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: magic_enum_containers.hpp:865
magic_enum::containers::bitset
bitset(V starter) -> bitset< V >
magic_enum::containers::set::value_comp
constexpr value_compare value_comp() const
Definition: magic_enum_containers.hpp:1083
magic_enum::enum_name
constexpr auto enum_name() noexcept -> detail::enable_if_t< decltype(V), string_view >
Definition: magic_enum.hpp:1290
magic_enum::containers::bitset::reference_impl::reference_impl
constexpr reference_impl(parent_t p, std::size_t i) noexcept
Definition: magic_enum_containers.hpp:508
magic_enum::containers::set::begin
constexpr const_iterator begin() const noexcept
Definition: magic_enum_containers.hpp:902
magic_enum::containers::array::index_type
Index index_type
Definition: magic_enum_containers.hpp:340
magic_enum::containers::set::insert
constexpr iterator insert(const_iterator, const value_type &value) noexcept
Definition: magic_enum_containers.hpp:949
std
magic_enum::containers::array::front
constexpr reference front() noexcept
Definition: magic_enum_containers.hpp:379
magic_enum::containers::detail::indexing< E, Cmp, std::enable_if_t< std::is_enum_v< std::decay_t< E > > &&(std::is_same_v< Cmp, std::less< E >>||std::is_same_v< Cmp, std::less<>>)> >::begin
static constexpr const E * begin() noexcept
Definition: magic_enum_containers.hpp:184
magic_enum::containers::to_array
constexpr std::enable_if_t<(enum_count< E >)==N), array< E, std::remove_cv_t< T > > > to_array(T(&a)[N])
Definition: magic_enum_containers.hpp:465
magic_enum::detail::find
constexpr std::size_t find(string_view str, char_type c) noexcept
Definition: magic_enum.hpp:312
magic_enum::containers::detail::FilteredIterator::operator--
constexpr FilteredIterator operator--(int)
Definition: magic_enum_containers.hpp:302
magic_enum::containers::array::end
constexpr const_iterator end() const noexcept
Definition: magic_enum_containers.hpp:399
magic_enum::containers::array::crbegin
constexpr const_iterator crbegin() const noexcept
Definition: magic_enum_containers.hpp:407
s2
@ s2
Definition: test.cpp:453
magic_enum::containers::set::insert
constexpr void insert(InputIt first, InputIt last) noexcept
Definition: magic_enum_containers.hpp:954
magic_enum::containers::array::end
constexpr iterator end() noexcept
Definition: magic_enum_containers.hpp:397
magic_enum::containers::get
constexpr std::enable_if_t<(std::is_integral_v< decltype(I)> &&I< enum_count< E >)), V & > get(array< E, V, Index > &a) noexcept
Definition: magic_enum_containers.hpp:1133
magic_enum::containers::array::data
constexpr pointer data() noexcept
Definition: magic_enum_containers.hpp:387
magic_enum::containers::array::container_type
std::array< V, enum_count< E >()> container_type
Definition: magic_enum_containers.hpp:341
magic_enum::containers::bitset::not_interested
static constexpr std::size_t not_interested
Definition: magic_enum_containers.hpp:497
magic_enum::containers::set::size
constexpr size_type size() const noexcept
Definition: magic_enum_containers.hpp:924
magic_enum::containers::set::erase
constexpr iterator erase(const_iterator first, const_iterator last) noexcept
Definition: magic_enum_containers.hpp:981
magic_enum::containers::set::operator!=
constexpr friend bool operator!=(const set &lhs, const set &rhs) noexcept
Definition: magic_enum_containers.hpp:1087
magic_enum::containers::bitset::bitset
constexpr bitset(detail::raw_access_t=raw_access) noexcept
Definition: magic_enum_containers.hpp:561
magic_enum::containers::array::rbegin
constexpr const_iterator rbegin() const noexcept
Definition: magic_enum_containers.hpp:405
magic_enum::containers::array::front
constexpr const_reference front() const noexcept
Definition: magic_enum_containers.hpp:381
magic_enum::containers::set::insert
constexpr void insert(std::initializer_list< value_type > ilist) noexcept
Definition: magic_enum_containers.hpp:960
magic_enum::containers::detail::is_transparent_v
constexpr bool is_transparent_v
Definition: magic_enum_containers.hpp:55
magic_enum::containers::array::const_reference
typename container_type::const_reference const_reference
Definition: magic_enum_containers.hpp:347
magic_enum::containers::bitset::reference_impl::operator=
constexpr reference_impl & operator=(bool v) noexcept
Definition: magic_enum_containers.hpp:513
magic_enum::containers::detail::indexing::at
static constexpr optional< std::size_t > at(E val) noexcept
Definition: magic_enum_containers.hpp:171
magic_enum::containers::array::at
constexpr const_reference at(E pos) const
Definition: magic_enum_containers.hpp:362
magic_enum::containers::set::set
constexpr set(V starter)
Definition: magic_enum_containers.hpp:882
magic_enum::containers::set::Getter
Definition: magic_enum_containers.hpp:843
magic_enum::containers::bitset::reference_impl::parent
parent_t parent
Definition: magic_enum_containers.hpp:504
magic_enum::containers::set::find
constexpr const_iterator find(const key_type &key) const noexcept
Definition: magic_enum_containers.hpp:1023
magic_enum::containers::array::operator<
constexpr friend bool operator<(const array &a1, const array &a2)
Definition: magic_enum_containers.hpp:439
magic_enum::containers::array::pointer
typename container_type::pointer pointer
Definition: magic_enum_containers.hpp:348
magic_enum::containers::array::at
constexpr reference at(E pos)
Definition: magic_enum_containers.hpp:355
magic_enum::containers::detail::indexing::it
static constexpr const E * it(std::size_t i) noexcept
Definition: magic_enum_containers.hpp:169
magic_enum::containers::detail::FilteredIterator
Definition: magic_enum_containers.hpp:247
magic_enum::containers::bitset::to_ullong
constexpr unsigned long long to_ullong(detail::raw_access_t raw) const
Definition: magic_enum_containers.hpp:816
magic_enum::containers::detail::lexicographical_compare
constexpr bool lexicographical_compare(T1 &&t1, T2 &&t2, Cmp &&cmp={}) noexcept
Definition: magic_enum_containers.hpp:76
magic_enum::containers::bitset< E, index_type >::index_type
index_type index_type
Definition: magic_enum_containers.hpp:556
magic_enum::containers::array::max_size
constexpr size_type max_size() const noexcept
Definition: magic_enum_containers.hpp:419
magic_enum::containers::set::size_type
std::size_t size_type
Definition: magic_enum_containers.hpp:854
magic_enum::containers::detail::FilteredIterator::operator++
constexpr FilteredIterator & operator++()
Definition: magic_enum_containers.hpp:282
magic_enum::containers::detail::FilteredIterator::getter
Getter getter
Definition: magic_enum_containers.hpp:252
magic_enum::containers::set::lower_bound
constexpr std::enable_if_t< detail::is_transparent_v< KC >, const_iterator > lower_bound(const K &x) const noexcept
Definition: magic_enum_containers.hpp:1063
magic_enum::containers::set::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition: magic_enum_containers.hpp:864
magic_enum::containers::detail::FilteredIterator::current
Iterator current
Definition: magic_enum_containers.hpp:251
magic_enum::containers::set::end
constexpr const_iterator end() const noexcept
Definition: magic_enum_containers.hpp:906
magic_enum::containers::bitset::set
constexpr bitset & set(E pos, bool value=true)
Definition: magic_enum_containers.hpp:743
magic_enum::containers::bitset::operator>>
friend std::istream & operator>>(std::istream &i, bitset &bs)
Definition: magic_enum_containers.hpp:822
magic_enum::containers::detail::FilteredIterator::last
Iterator last
Definition: magic_enum_containers.hpp:250
magic_enum::containers::bitset::any
constexpr bool any() const noexcept
Definition: magic_enum_containers.hpp:676
magic_enum::containers::set::erase
constexpr iterator erase(const_iterator pos) noexcept
Definition: magic_enum_containers.hpp:976
magic_enum::containers::array::size_type
typename container_type::size_type size_type
Definition: magic_enum_containers.hpp:344
magic_enum::containers::detail::FilteredIterator::value_type
std::remove_reference_t< std::invoke_result_t< Getter, Parent, Iterator > > value_type
Definition: magic_enum_containers.hpp:256
magic_enum::containers::set::const_pointer
const value_type * const_pointer
Definition: magic_enum_containers.hpp:861


magic_enum
Author(s):
autogenerated on Fri Feb 21 2025 03:20:19