10#ifndef MAXMATRIX_SRC_UTILITY_ARRAY_H_
11#define MAXMATRIX_SRC_UTILITY_ARRAY_H_
41template <
typename T,
size_t N>
44 static_assert(N > 0,
"max_matrix::array needs at least one element");
96template <
typename Value>
98 return value != Value{0} && !(value > Value{0});
117template <
typename T,
typename Value,
typename Braced = T>
124 static constexpr bool Fits(Value value) {
125 return static_cast<Value
>(
static_cast<T
>(value)) == value &&
135 static constexpr T
Of(Value value) {
145template <
typename T,
typename Value>
152 static constexpr T
Of(Value
const& value) {
return value; }
184template <
typename T,
typename... Values>
The attributes of a later standard, as macros, where the compiler has them.
#define MAXMATRIX_NODISCARD
Marks a function whose result must not be dropped: the compiler warns where it is.
Definition MaxMatrixAttributes.h:37
T ValueOutOfRange()
Declared only, so that make_array() stops the build with its name.
constexpr array< T, sizeof...(Values)> make_array(Values... values)
Returns an array of T of its values, with the size taken from them.
Definition array.h:185
constexpr bool IsNegative(Value value)
Returns whether value is below 0, without comparing a type that has no sign with 0,...
Definition array.h:97
T && DeclVal()
Declared only: in a decltype, a value of type T, where nothing is evaluated, as std::declval(),...
A C array of N elements that knows its size.
Definition array.h:42
MAXMATRIX_NODISCARD constexpr size_type size() const
Returns the number of elements, N.
Definition array.h:58
T value_type
Definition array.h:46
T & operator[](size_type index)
Returns the element at index, unchecked.
Definition array.h:65
T elements[N]
The elements.
Definition array.h:55
MAXMATRIX_NODISCARD T * data()
Returns the address of the first element, as a C array gives it.
Definition array.h:73
size_t size_type
Definition array.h:47
constexpr T const & operator[](size_type index) const
Returns the element at index, unchecked.
Definition array.h:68
MAXMATRIX_NODISCARD constexpr T const * data() const
Returns the address of the first element, as a C array gives it.
Definition array.h:76
static constexpr T Of(Value const &value)
Returns value as an element.
Definition array.h:152
Converts a value of make_array() that would narrow, a number, into an element.
Definition array.h:118
static constexpr T Of(Value value)
Returns value as an element, or stops the build if it does not fit.
Definition array.h:135
static constexpr bool Fits(Value value)
Returns whether value is the same as an element as it was.
Definition array.h:124