24 std::unsigned_integral<Value> &&
25 std::same_as<Value, std::remove_cv_t<Value>> &&
26 !std::same_as<Value, bool> && (std::numeric_limits<Value>::digits <= 64);
39template <
class Impl, IntegerVectorValue Value = std::u
int64_t>
61 return impl().value_at_impl(position);
69 if (position >=
size()) {
70 throw std::out_of_range(
"Integer-vector position is out of range");
72 return (*
this)[position];
86 if (begin > vector_size || output.size() > vector_size - begin) {
87 throw std::out_of_range(
"Integer-vector copy range is out of bounds");
89 impl().copy_to_impl(begin, output);
98 requires requires(const Impl& concrete) {
99 { concrete.memory_usage_bytes_impl() } -> std::convertible_to<size_type>;
102 return impl().memory_usage_bytes_impl();
107 const Impl& impl()
const {
return static_cast<const Impl&
>(*this); }
121template <
class Impl, IntegerVectorValue Value = std::u
int64_t>
132 return impl().lower_bound_index_impl(x);
140 return impl().upper_bound_index_impl(x);
146 return position != this->
size() && (*this)[position] == x;
156 const Impl& impl()
const {
return static_cast<const Impl&
>(*this); }
CRTP facade for an immutable positional integer vector.
Definition integer_vector.h:40
bool empty() const
Return whether the vector has no elements.
Definition integer_vector.h:52
value_type at(size_type position) const
Read the element at zero-based position with bounds checking.
Definition integer_vector.h:68
void copy_to(size_type begin, std::span< value_type > output) const
Copy a checked contiguous source range into output.
Definition integer_vector.h:84
value_type operator[](size_type position) const
Read the element at zero-based position without bounds checking.
Definition integer_vector.h:60
size_type size() const
Return the logical number of elements.
Definition integer_vector.h:49
Value value_type
Stored integer type.
Definition integer_vector.h:43
size_type memory_usage_bytes() const
Return total memory owned by this vector when supported.
Definition integer_vector.h:97
std::size_t size_type
Type used for element counts and zero-based positions.
Definition integer_vector.h:46
CRTP refinement for duplicate-preserving monotone integer vectors.
Definition integer_vector.h:122
size_type upper_bound_index(value_type x) const
Return the first index whose value is greater than x.
Definition integer_vector.h:139
size_type lower_bound_index(value_type x) const
Return the first index whose value is greater than or equal to x.
Definition integer_vector.h:131
size_type count(value_type x) const
Return the number of elements equal to x.
Definition integer_vector.h:150
bool contains(value_type x) const
Return whether at least one element equals x.
Definition integer_vector.h:144
An unsigned integer-vector value type no wider than 64 bits.
Definition integer_vector.h:23