23 return in * __CHAR_BIT__;
30 static_assert(N > 0 && (N & (N - 1)) == 0);
32 return 1U +
log2<(N >> 1)>();
35 constexpr size_t log2<1U>()
41 template<
typename T,
size_t N>
42 [[deprecated(
"Use std::extent_v<decltype(arr)> for array_size(arr)")]]
55 requires std::is_integral_v<T>
58 return (value + divisor - 1) / divisor;
68 requires std::is_integral_v<T>
73 static_assert(align_up(15, 16) == 16);
74 static_assert(align_up(28, 16) == 32);
75 static_assert(align_up(17, 8) == 24);
84 template<auto Multiple,
typename T>
85 requires std::is_integral_v<T> && (std::in_range<T>(Multiple)) &&
86 ((Multiple & (Multiple - 1)) == 0)
89 return (value + Multiple - 1) & -Multiple;
91 static_assert(align_up<16>(15) == 16);
92 static_assert(align_up<16>(28) == 32);
93 static_assert(align_up<8>(17) == 24);
107 NoCopyNoMove() =
default;
108 NoCopyNoMove(
const NoCopyNoMove &) =
delete;
109 NoCopyNoMove &operator=(
const NoCopyNoMove &) =
delete;
110 NoCopyNoMove(NoCopyNoMove &&) =
delete;
111 NoCopyNoMove &operator=(NoCopyNoMove &&) =
delete;
112 ~NoCopyNoMove() =
default;
149 if (pointer ==
nullptr)
162 if (pointer ==
nullptr)
176 using Result =
decltype(f(std::declval<T &>()));
177 if constexpr (std::is_same_v<void, Result>)
179 if (pointer !=
nullptr)
187 if (pointer !=
nullptr)
191 return Result{
nullptr};
OptionalReference(T &value)
Construct the optional wrapper from a real value.
T & value_or(T &defaultValue)
Returns a reference to the wrapped value if present or the provided default value if not.
T value_or(T defaultValue)
Returns a copy of the wrapped value if present or the provided default value if not.
OptionalReference(std::nullptr_t)
Construct the optional wrapper from not-present value.
auto and_then(auto &&f)
If this object holds a value then apply f to it and return the result, otherwise return the result of...
constexpr size_t log2()
Compute the log base 2 of a power of 2.
constexpr size_t bytes_to_bits(size_t in)
Turn a byte count into a bit count.
constexpr T align_up(T value, T multiple)
Return the smallest multiple greater than or equal to value.
constexpr T round_up_divide(T value, T divisor)
Divide value by divisor, rounding up, unlike /.
constexpr size_t array_size(T(&a)[N])
Return the extent of an array.