OGLplus  (0.59.0) a C++ wrapper for rendering APIs

biteset.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_BITESET_HPP
10 #define EAGINE_BITESET_HPP
11 
12 #include "assert.hpp"
13 #include "byteset.hpp"
14 #include "int_constant.hpp"
15 #include <climits>
16 #include <cstdint>
17 #include <iterator>
18 #include <type_traits>
19 #include <utility>
20 
21 namespace eagine {
22 
26 template <typename std::size_t B>
27 using biteset_cell_type = std::conditional_t<
28  (B <= 8),
29  std::uint_least8_t,
30  std::conditional_t<
31  (B <= 16),
32  std::uint_least16_t,
33  std::conditional_t<
34  (B <= 32),
35  std::uint_least32_t,
36  std::conditional_t<(B <= 64), std::uint_least64_t, void>>>>;
37 
38 template <std::size_t N, std::size_t B, typename T = biteset_cell_type<B>>
39 class biteset;
40 
45 template <typename BiS>
47 
53 template <typename BiS>
55 public:
57  using size_type = typename BiS::size_type;
58 
60  using value_type = typename BiS::value_type;
61 
62  using self = biteset_value_proxy_base;
64 
65  constexpr biteset_value_proxy_base(BiS& bs, size_type pos) noexcept
66  : _ptr{&bs}
67  , _pos{pos} {}
68 
70  constexpr auto is_valid() const noexcept -> bool {
71  return (_ptr != nullptr) && (_pos < _ptr->size());
72  }
73 
76  constexpr auto get() const noexcept -> value_type {
77  return EAGINE_CONSTEXPR_ASSERT(is_valid(), _ptr->get(_pos));
78  }
79 
82  void set(value_type val) noexcept {
83  EAGINE_CONSTEXPR_ASSERT(is_valid(), _ptr->set(_pos, val));
84  }
85 
86  void swap(self& other) noexcept {
87  using std::swap;
88  EAGINE_ASSERT(_ptr != nullptr);
89  EAGINE_ASSERT(_ptr == other._ptr);
90  value_type a = this->get();
91  value_type b = other.get();
92  swap(a, b);
93  this->set(a);
94  other.set(b);
95  }
96 
100  constexpr operator value_type() const noexcept {
101  return get();
102  }
103 
105  friend constexpr auto operator==(const self& a, const self& b) noexcept {
106  return a.get() == b.get();
107  }
108 
110  friend constexpr auto operator!=(const self& a, const self& b) noexcept {
111  return a.get() != b.get();
112  }
113 
115  friend constexpr auto operator<(const self& a, const self& b) noexcept {
116  return a.get() < b.get();
117  }
118 
120  friend constexpr auto operator<=(const self& a, const self& b) noexcept {
121  return a.get() <= b.get();
122  }
123 
125  friend constexpr auto operator>(const self& a, const self& b) noexcept {
126  return a.get() > b.get();
127  }
128 
130  friend constexpr auto operator>=(const self& a, const self& b) noexcept {
131  return a.get() >= b.get();
132  }
133 
134 protected:
135  BiS* _ptr{nullptr};
136  size_type _pos{0};
137 };
138 
143 template <std::size_t N, std::size_t B, typename T>
144 class biteset_value_proxy<const biteset<N, B, T>>
145  : public biteset_value_proxy_base<const biteset<N, B, T>> {
147 
148 public:
149  using size_type = typename _base::size_type;
150  using self = biteset_value_proxy;
151 
152  constexpr biteset_value_proxy(
153  const biteset<N, B, T>& bs,
154  size_type pos) noexcept
155  : _base{bs, pos} {}
156 };
157 
162 template <std::size_t N, std::size_t B, typename T>
164  : public biteset_value_proxy_base<biteset<N, B, T>> {
166  using _base::_pos;
167  using _base::_ptr;
168 
169 public:
170  using size_type = typename _base::size_type;
171  using value_type = typename _base::value_type;
172  using self = biteset_value_proxy;
173 
174  constexpr biteset_value_proxy(biteset<N, B, T>& bs, size_type pos) noexcept
175  : _base{bs, pos} {}
176 
177  constexpr biteset_value_proxy(biteset_value_proxy&& temp) noexcept(
178  std::is_nothrow_move_constructible_v<_base>) = default;
179  constexpr biteset_value_proxy(const biteset_value_proxy&) noexcept(
180  std::is_nothrow_copy_constructible_v<_base>) = delete;
181 
182  auto operator=(biteset_value_proxy&& temp) noexcept
183  -> biteset_value_proxy& {
184  this->set(temp.get());
185  return *this;
186  }
187  auto operator=(const biteset_value_proxy&) noexcept(
188  std::is_nothrow_copy_assignable_v<_base>) = delete;
189 
190  ~biteset_value_proxy() noexcept = default;
191 
193  auto operator=(const T& v) noexcept -> self& {
194  this->set(v);
195  return *this;
196  }
197 };
198 
199 template <typename BiS>
200 static inline void
201 swap(biteset_value_proxy<BiS>&& a, biteset_value_proxy<BiS>&& b) noexcept {
202  return a.swap(b);
203 }
204 
205 template <typename BiS>
206 class biteset_iterator;
207 
208 template <typename BiS>
209 class biteset_iterator_base {
210 public:
211  using self = biteset_iterator_base;
212  using derived = biteset_iterator<BiS>;
213  using size_type = typename BiS::size_type;
214  using difference_type = typename BiS::difference_type;
215 
216  void swap(self& other) noexcept {
217  using std::swap;
218  EAGINE_ASSERT(_ptr == other._ptr);
219  swap(_pos, other._pos);
220  }
221 
222  auto operator++() noexcept -> auto& {
223  ++_pos;
224  return *static_cast<derived*>(this);
225  }
226 
227  auto operator++(int) noexcept -> const derived {
228  derived that = *static_cast<derived*>(this);
229  ++_pos;
230  return that;
231  }
232 
233  auto operator--() noexcept -> auto& {
234  --_pos;
235  return *static_cast<derived*>(this);
236  }
237 
238  auto operator--(int) noexcept -> const derived {
239  derived that = *static_cast<derived*>(this);
240  --_pos;
241  return that;
242  }
243 
244  auto operator+=(size_type n) noexcept -> auto& {
245  _pos += n;
246  return *static_cast<derived*>(this);
247  }
248 
249  auto operator-=(size_type n) noexcept -> auto& {
250  _pos -= n;
251  return *static_cast<derived*>(this);
252  }
253 
254  friend auto operator+(const self& a, difference_type n) noexcept {
255  return derived(*a._ptr, a._pos + n);
256  }
257 
258  friend auto operator+(difference_type n, const self& a) noexcept {
259  return derived(*a._ptr, n + a._pos);
260  }
261 
262  friend auto operator-(const self& a, difference_type n) noexcept {
263  return derived(*a._ptr, a._pos - n);
264  }
265 
266  friend auto operator-(const self& a, const self& b) noexcept
267  -> difference_type {
268  return a._pos - b._pos;
269  }
270 
271  friend constexpr auto operator==(const self& a, const self& b) noexcept {
272  return _cmp(a, b) == 0;
273  }
274 
275  friend constexpr auto operator!=(const self& a, const self& b) noexcept {
276  return _cmp(a, b) != 0;
277  }
278 
279  friend constexpr auto operator<(const self& a, const self& b) noexcept {
280  return _cmp(a, b) < 0;
281  }
282 
283  friend constexpr auto operator<=(const self& a, const self& b) noexcept {
284  return _cmp(a, b) <= 0;
285  }
286 
287  friend constexpr auto operator>(const self& a, const self& b) noexcept {
288  return _cmp(a, b) > 0;
289  }
290 
291  friend constexpr auto operator>=(const self& a, const self& b) noexcept {
292  return _cmp(a, b) >= 0;
293  }
294 
295 protected:
296  constexpr biteset_iterator_base(BiS& bs, size_type pos) noexcept
297  : _ptr{&bs}
298  , _pos{pos} {}
299 
300  constexpr biteset_iterator_base() noexcept = default;
301 
302  constexpr auto is_valid() const noexcept {
303  return (_ptr != nullptr) && (_pos < _ptr->size());
304  }
305 
306  static constexpr auto _cmp(const self& a, const self& b) noexcept
307  -> difference_type {
308  return EAGINE_CONSTEXPR_ASSERT(
309  (a._ptr != nullptr) && (a._ptr == b._ptr), a._pos - b._pos);
310  }
311 
312  BiS* _ptr{nullptr};
313  size_type _pos{0};
314 };
315 
316 template <typename BiS>
317 static inline void
318 swap(biteset_iterator_base<BiS>& a, biteset_iterator_base<BiS>& b) noexcept {
319  return a.swap(b);
320 }
321 
322 template <std::size_t N, std::size_t B, typename T>
323 class biteset_iterator<const biteset<N, B, T>>
324  : public biteset_iterator_base<const biteset<N, B, T>> {
325  using _base = biteset_iterator_base<const biteset<N, B, T>>;
326  using _base::_pos;
327  using _base::_ptr;
328  using _base::is_valid;
329 
330 public:
331  using size_type = typename biteset<N, B, T>::size_type;
332  using difference_type = typename biteset<N, B, T>::difference_type;
333  using value_type = typename biteset<N, B, T>::value_type;
334  using const_proxy = biteset_value_proxy<const biteset<N, B, T>>;
335  using reference = const_proxy;
336  using const_reference = const_proxy;
337  using pointer = const_proxy;
338  using const_pointer = const_proxy;
339  using iterator_category = std::random_access_iterator_tag;
340  using self = biteset_iterator;
341 
342  constexpr biteset_iterator(
343  const biteset<N, B, T>& bs,
344  size_type pos) noexcept
345  : _base{bs, pos} {}
346 
347  constexpr biteset_iterator() = default;
348 
349  constexpr auto operator*() const noexcept -> const_proxy {
350  return EAGINE_CONSTEXPR_ASSERT(is_valid(), const_proxy(*_ptr, _pos));
351  }
352 };
353 
357 template <std::size_t N, std::size_t B, typename T>
358 class biteset_iterator<biteset<N, B, T>>
359  : public biteset_iterator_base<biteset<N, B, T>> {
360  using _base = biteset_iterator_base<biteset<N, B, T>>;
361  using _base::_cmp;
362  using _base::_pos;
363  using _base::_ptr;
364  using _base::is_valid;
365 
366 public:
367  using self = biteset_iterator;
368  using size_type = typename biteset<N, B, T>::size_type;
369  using difference_type = typename biteset<N, B, T>::difference_type;
370  using value_type = typename biteset<N, B, T>::value_type;
373  using reference = proxy;
375  using pointer = proxy;
376  using const_pointer = const_proxy;
377 
379  using iterator_category = std::random_access_iterator_tag;
380 
381  constexpr biteset_iterator(biteset<N, B, T>& bs, size_type pos) noexcept
382  : _base{bs, pos} {}
383 
384  constexpr biteset_iterator() noexcept = default;
385 
386  constexpr auto operator*() noexcept -> proxy {
387  return EAGINE_CONSTEXPR_ASSERT(is_valid(), proxy(*_ptr, _pos));
388  }
389 
390  constexpr auto operator*() const noexcept -> const_proxy {
391  return EAGINE_CONSTEXPR_ASSERT(is_valid(), const_proxy(*_ptr, _pos));
392  }
393 
394  constexpr auto operator->() noexcept -> proxy {
395  return EAGINE_CONSTEXPR_ASSERT(is_valid(), proxy(*_ptr, _pos));
396  }
397 
398  auto operator->() const noexcept -> const_proxy {
399  return EAGINE_CONSTEXPR_ASSERT(is_valid(), const_proxy(*_ptr, _pos));
400  }
401 };
402 
409 template <std::size_t N, std::size_t B, typename T>
410 class biteset {
411 public:
412  static constexpr const std::size_t store_size =
413  ((N * B) / CHAR_BIT) + (((N * B) % CHAR_BIT != 0) ? 1 : 0);
414 
415 private:
416  using _bytes_t = byteset<store_size>;
417 
418  // the number of useful bits in T
419  static constexpr const std::size_t _bite_s = B;
420  // the number of bits in a byte
421  static constexpr const std::size_t _byte_s = CHAR_BIT;
422  // the number of all bits in T
423  static constexpr const std::size_t _cell_s = sizeof(T) * CHAR_BIT;
424 
425 public:
426  static_assert((B > 0), "bite size must be greater than zero");
427  static_assert((N > 0), "bite count must be greater than zero");
428  static_assert(
429  (_cell_s >= _bite_s),
430  "bite with B bits size does not fit into type T");
431  static_assert(std::is_integral_v<T>, "T must be integral type");
432 
435 
438 
440  using value_type = T;
441 
443  using iterator = biteset_iterator<biteset>;
444 
446  using const_iterator = biteset_iterator<const biteset>;
447 
449  constexpr biteset() noexcept = default;
450 
452  template <
453  typename... P,
454  typename = std::enable_if_t<
455  (sizeof...(P) == N) &&
456  std::conjunction_v<std::true_type, std::is_convertible<P, T>...>>>
457  explicit constexpr biteset(P... p) noexcept
458  : _bytes{_make_bytes(T(p)...)} {}
459 
460  explicit constexpr biteset(_bytes_t init) noexcept
461  : _bytes{init} {}
462 
464  template <typename UIntT>
465  static constexpr auto from_value(UIntT init) noexcept {
466  return biteset{_bytes_t{init}};
467  }
468 
471  constexpr auto size() const noexcept -> size_type {
472  return N;
473  }
474 
477  constexpr auto get(size_type i) const noexcept {
478  return _get_cell(std::size_t(i));
479  }
480 
483  void set(size_type i, T value) noexcept {
484  _set_cell(std::size_t(i), value);
485  }
486 
488  auto begin() const noexcept -> const_iterator {
489  return {*this, 0};
490  }
491 
493  auto end() const noexcept -> const_iterator {
494  return {*this, N};
495  }
496 
498  auto begin() noexcept -> iterator {
499  return {*this, 0};
500  }
501 
503  auto end() noexcept -> iterator {
504  return {*this, N};
505  }
506 
508  constexpr auto operator[](size_type i) const noexcept
510  return {*this, i};
511  }
512 
514  constexpr auto operator[](size_type i) noexcept
516  return {*this, i};
517  }
518 
520  friend constexpr auto
521  operator==(const biteset& a, const biteset& b) noexcept {
522  return a.bytes() == b.bytes();
523  }
524 
526  friend constexpr auto
527  operator!=(const biteset& a, const biteset& b) noexcept {
528  return a.bytes() != b.bytes();
529  }
530 
532  friend constexpr auto
533  operator<(const biteset& a, const biteset& b) noexcept {
534  return a.bytes() < b.bytes();
535  }
536 
538  friend constexpr auto
539  operator<=(const biteset& a, const biteset& b) noexcept {
540  return a.bytes() <= b.bytes();
541  }
542 
544  friend constexpr auto
545  operator>(const biteset& a, const biteset& b) noexcept {
546  return a.bytes() > b.bytes();
547  }
548 
550  friend constexpr auto
551  operator>=(const biteset& a, const biteset& b) noexcept {
552  return a.bytes() >= b.bytes();
553  }
554 
556  constexpr auto bytes() const noexcept -> const byteset<store_size>& {
557  return _bytes;
558  }
559 
560 private:
561  _bytes_t _bytes{};
562 
563  static constexpr auto _min_s(std::size_t x, std::size_t y) noexcept
564  -> std::size_t {
565  return (x < y) ? x : y;
566  }
567 
568  static constexpr auto
569  _extract_init_bits(T init, std::size_t ofs, std::size_t len) noexcept
570  -> byte {
571  // NOLINT(hicpp-signed-bitwise)
572  return static_cast<byte>(init >> (_bite_s - ofs - len)) &
573  // NOLINT(hicpp-signed-bitwise)
574  static_cast<byte>((1U << len) - 1U);
575  }
576 
577  template <std::size_t L>
578  static constexpr auto _do_get_byte_bits(
579  const T (&init)[N],
580  byte state,
581  std::size_t bo,
582  std::size_t bl,
583  std::size_t bb,
584  std::size_t be,
585  std::size_t cb,
586  std::size_t ce,
587  size_constant<L>) noexcept {
588  return _get_byte_bits(
589  init,
590  static_cast<byte>(state << bl) |
591  _extract_init_bits(cb < N ? init[cb] : T(0), bo, bl),
592  bb + bl,
593  be,
594  cb + 1,
595  ce,
596  size_constant<L + 1>{});
597  }
598 
599  static constexpr auto _get_byte_bits(
600  const T (&)[N],
601  byte state,
602  std::size_t,
603  std::size_t,
604  std::size_t,
605  std::size_t,
606  size_constant<_byte_s>) noexcept {
607  return state;
608  }
609 
610  template <std::size_t L>
611  static constexpr auto _get_byte_bits(
612  const T (&init)[N],
613  byte state,
614  std::size_t bb,
615  std::size_t be,
616  std::size_t cb,
617  std::size_t ce,
618  size_constant<L> l) noexcept {
619  return (bb >= be)
620  ? state
621  : _do_get_byte_bits(
622  init,
623  state,
624  (bb - cb * _bite_s),
625  _min_s((be - bb), (_bite_s - (bb - cb * _bite_s))),
626  bb,
627  be,
628  cb,
629  ce,
630  l);
631  }
632 
633  static constexpr auto
634  _get_byte_bits(const T (&init)[N], std::size_t bb, std::size_t be) noexcept {
635  return _get_byte_bits(
636  init, byte(0), bb, be, bb / _bite_s, be / _bite_s, size_constant<1>{});
637  }
638 
639  static constexpr auto _get_byte(const T (&init)[N], std::size_t i) noexcept {
640  return (B == _byte_s)
641  ? static_cast<byte>(init[i])
642  : _get_byte_bits(init, (i + 0) * _byte_s, (i + 1) * _byte_s);
643  }
644 
645  static constexpr auto
646  _extract_cell_bits(byte by, std::size_t ofs, std::size_t len) noexcept
647  -> T {
648  // NOLINTNEXTLINE(hicpp-signed-bitwise)
649  return T(by >> (_byte_s - ofs - len)) & T((1 << len) - 1);
650  }
651 
652  template <std::size_t L>
653  constexpr auto _do_get_cell_bits(
654  T state,
655  std::size_t bo,
656  std::size_t bl,
657  std::size_t bb,
658  std::size_t be,
659  std::size_t cb,
660  std::size_t ce,
661  size_constant<L>) const noexcept -> T {
662  return _get_cell_bits(
663  T(state << bl) | _extract_cell_bits(_bytes[size_type(cb)], bo, bl),
664  bb + bl,
665  be,
666  cb + 1,
667  ce,
668  size_constant<L + 1>{});
669  }
670 
671  static constexpr auto _get_cell_bits(
672  T state,
673  std::size_t,
674  std::size_t,
675  std::size_t,
676  std::size_t,
677  size_constant<_byte_s>) noexcept -> T {
678  return state;
679  }
680 
681  template <std::size_t L>
682  constexpr auto _get_cell_bits(
683  T state,
684  std::size_t bb,
685  std::size_t be,
686  std::size_t cb,
687  std::size_t ce,
688  size_constant<L> l) const noexcept -> T {
689  return (bb >= be)
690  ? state
691  : _do_get_cell_bits(
692  state,
693  (bb - cb * _byte_s),
694  _min_s((be - bb), (_byte_s - (bb - cb * _byte_s))),
695  bb,
696  be,
697  cb,
698  ce,
699  l);
700  }
701 
702  constexpr auto _get_cell_bits(std::size_t bb, std::size_t be) const noexcept
703  -> T {
704  return _get_cell_bits(
705  byte(0), bb, be, bb / _byte_s, be / _byte_s, size_constant<1>{});
706  }
707 
708  constexpr auto _get_cell(std::size_t i) const noexcept -> T {
709  return (B == _byte_s)
710  ? T(_bytes[size_type(i)])
711  : _get_cell_bits((i + 0) * _bite_s, (i + 1) * _bite_s);
712  }
713 
714  static constexpr void
715  _store_cell_bits(T v, byte& by, std::size_t ofs, std::size_t len) noexcept {
716  const auto msk =
717  // NOLINTNEXTLINE(hicpp-signed-bitwise)
718  static_cast<byte>(((1U << len) - 1U) << (_byte_s - ofs - len));
719  // NOLINTNEXTLINE(hicpp-signed-bitwise)
720  by ^= (by & msk);
721  by |= (v << (_byte_s - ofs - len));
722  }
723 
724  template <std::size_t L>
725  void _do_set_cell_bits(
726  T state,
727  std::size_t bo,
728  std::size_t bl,
729  std::size_t bb,
730  std::size_t be,
731  std::size_t cb,
732  std::size_t ce,
733  size_constant<L>) noexcept {
734  _store_cell_bits(
735  (state >> (_cell_s - bl)), _bytes[size_type(cb)], bo, bl);
736  return _set_cell_bits(
737  T(state << bl), bb + bl, be, cb + 1, ce, size_constant<L + 1>{});
738  }
739 
740  static constexpr void _set_cell_bits(
741  T,
742  std::size_t,
743  std::size_t,
744  std::size_t,
745  std::size_t,
746  size_constant<_byte_s>) noexcept {}
747 
748  template <std::size_t L>
749  void _set_cell_bits(
750  T state,
751  std::size_t bb,
752  std::size_t be,
753  std::size_t cb,
754  std::size_t ce,
755  size_constant<L> l) noexcept {
756  if(bb < be) {
757  _do_set_cell_bits(
758  state,
759  (bb - cb * _byte_s),
760  _min_s((be - bb), (_byte_s - (bb - cb * _byte_s))),
761  bb,
762  be,
763  cb,
764  ce,
765  l);
766  }
767  }
768 
769  void _set_cell_bits(T state, std::size_t bb, std::size_t be) noexcept {
770  return _set_cell_bits(
771  state, bb, be, bb / _byte_s, be / _byte_s, size_constant<1>{});
772  }
773 
774  void _set_cell(std::size_t i, T value) noexcept {
775  if(B == _byte_s) {
776  _bytes[size_type(i)] = byte(value);
777  } else {
778  _set_cell_bits(
779  T(value << (_cell_s - _bite_s)),
780  (i + 0) * _bite_s,
781  (i + 1) * _bite_s);
782  }
783  }
784 
785  template <std::size_t... I>
786  static constexpr auto
787  _do_make_bytes(const T (&init)[N], std::index_sequence<I...>) noexcept {
788  return _bytes_t{_get_byte(init, size_constant<I>{})...};
789  }
790 
791  template <typename... P>
792  static constexpr auto _make_bytes(P... p) noexcept {
793  return _do_make_bytes(
794  {T(p)...}, std::make_index_sequence<store_size>{});
795  }
796 };
797 
798 } // namespace eagine
799 
800 #endif // EAGINE_BITESET_HPP
constexpr friend auto operator==(const self &a, const self &b) noexcept
Equality comparison.
Definition: biteset.hpp:105
value_type
Value tree value element data type enumeration.
Definition: interface.hpp:27
auto begin() const noexcept -> const_iterator
Returns an iterator to the start of the sequence.
Definition: biteset.hpp:488
constexpr friend auto operator==(const biteset &a, const biteset &b) noexcept
Equality comparison.
Definition: biteset.hpp:521
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
biteset_iterator< const biteset > const_iterator
Alias for const iterator type.
Definition: biteset.hpp:446
static constexpr auto operator>=(const valid_if< T, P1 > &v1, const valid_if< T, P2 > &v2) noexcept -> tribool
Greater-equal comparison of two conditionally valid values.
Definition: decl.hpp:213
void set(size_type i, T value) noexcept
Sets the i-th element in this biteset.
Definition: biteset.hpp:483
static constexpr auto operator>(const valid_if< T, P1 > &v1, const valid_if< T, P2 > &v2) noexcept -> tribool
Greater-than comparison of two conditionally valid values.
Definition: decl.hpp:191
constexpr friend auto operator>(const self &a, const self &b) noexcept
Greater-than comparison.
Definition: biteset.hpp:125
Common code is placed in this namespace.
Definition: eagine.hpp:21
constexpr auto get(size_type i) const noexcept
Returns the i-th element in this biteset.
Definition: biteset.hpp:477
static constexpr auto operator<=(const valid_if< T, P1 > &v1, const valid_if< T, P2 > &v2) noexcept -> tribool
Less-equal comparison of two conditionally valid values.
Definition: decl.hpp:202
constexpr biteset() noexcept=default
Default constructor.
auto operator=(const T &v) noexcept -> self &
Assigns the specified value to the referenceb biteset element.
Definition: biteset.hpp:193
Specialization of biteset proxy for const biteset values.
Definition: biteset.hpp:144
constexpr friend auto operator<=(const biteset &a, const biteset &b) noexcept
Less-equal comparison.
Definition: biteset.hpp:539
constexpr friend auto operator<=(const self &a, const self &b) noexcept
Less-equal comparison.
Definition: biteset.hpp:120
constexpr friend auto operator<(const self &a, const self &b) noexcept
Less-than comparison.
Definition: biteset.hpp:115
static constexpr auto from_value(UIntT init) noexcept
Constructs a biteset from the specified values splitting bit groups of size=B.
Definition: biteset.hpp:465
biteset_iterator< biteset > iterator
Alias for iterator type.
Definition: biteset.hpp:443
constexpr auto bytes() const noexcept -> const byteset< store_size > &
Converts this biteset into a byteset.
Definition: biteset.hpp:556
span_size_t difference_type
Alias for difference type.
Definition: biteset.hpp:437
constexpr auto size() const noexcept -> size_type
Returns the number of elements in this biteset.
Definition: biteset.hpp:471
std::random_access_iterator_tag iterator_category
Iterator category.
Definition: biteset.hpp:379
T value_type
Alias for element value type.
Definition: biteset.hpp:440
static auto operator+(const fixed_size_string< N1 > &s1, const fixed_size_string< N2 > &s2) noexcept
Concatenation operator for fixed_size_string.
Definition: fixed_size_str.hpp:135
constexpr auto operator[](size_type i) noexcept -> biteset_value_proxy< biteset >
Subscript operator.
Definition: biteset.hpp:514
static constexpr auto operator!=(const valid_if< T, P1 > &v1, const valid_if< T, P2 > &v2) noexcept -> tribool
Non-equality comparison of two conditionally valid values.
Definition: decl.hpp:169
unsigned char byte
Byte type alias.
Definition: types.hpp:24
constexpr friend auto operator>=(const self &a, const self &b) noexcept
Greater-equal comparison.
Definition: biteset.hpp:130
auto end() const noexcept -> const_iterator
Returns an iterator past the end of the sequence.
Definition: biteset.hpp:493
constexpr friend auto operator>=(const biteset &a, const biteset &b) noexcept
Greater-equal comparison.
Definition: biteset.hpp:551
constexpr friend auto operator!=(const self &a, const self &b) noexcept
Non-equality comparison.
Definition: biteset.hpp:110
Specialization of biteset proxy for mutable biteset values.
Definition: biteset.hpp:163
constexpr friend auto operator<(const biteset &a, const biteset &b) noexcept
Less-than comparison.
Definition: biteset.hpp:533
std::conditional_t<(B<=8), std::uint_least8_t, std::conditional_t<(B<=16), std::uint_least16_t, std::conditional_t<(B<=32), std::uint_least32_t, std::conditional_t<(B<=64), std::uint_least64_t, void > >> > biteset_cell_type
Selects the appropriate type for biteset element representation.
Definition: biteset.hpp:36
void set(value_type val) noexcept
Sets the value of the referenced biteset element.
Definition: biteset.hpp:82
constexpr friend auto operator>(const biteset &a, const biteset &b) noexcept
Greater-than comparison.
Definition: biteset.hpp:545
auto operator==(message_id l, static_message_id< ClassId, MethodId > r) noexcept
Equality comparison between message_id and static_message_id.
Definition: message_id.hpp:131
auto begin() noexcept -> iterator
Returns a const iterator to the start of the sequence.
Definition: biteset.hpp:498
constexpr auto operator[](size_type i) const noexcept -> biteset_value_proxy< const biteset >
Subscript operator.
Definition: biteset.hpp:508
auto end() noexcept -> iterator
Returns a const iterator past the end of the sequence.
Definition: biteset.hpp:503
typename biteset< N, B, T > ::size_type size_type
Alias for size type.
Definition: biteset.hpp:57
Proxy class that can be used to access elements in a biteset.
Definition: biteset.hpp:46
typename biteset< N, B, T > ::value_type value_type
Alias for element value type.
Definition: biteset.hpp:60
Sequence of unsigned integer values with specified number bits.
Definition: biteset.hpp:39
Base class for biteset value proxy.
Definition: biteset.hpp:54
span_size_t size_type
Alias for size type.
Definition: biteset.hpp:434
static constexpr auto operator<(const valid_if< T, P1 > &v1, const valid_if< T, P2 > &v2) noexcept -> tribool
Less-than comparison of two conditionally valid values.
Definition: decl.hpp:180
constexpr auto get() const noexcept -> value_type
Gets the value of the referenced biteset element.
Definition: biteset.hpp:76
constexpr auto is_valid() const noexcept -> bool
Indicates if this is a valid proxy object that can be used for access.
Definition: biteset.hpp:70
constexpr friend auto operator!=(const biteset &a, const biteset &b) noexcept
Non-equality comparison.
Definition: biteset.hpp:527

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).