[wpiutil] Make wpi::array constexpr (#4278)

This commit is contained in:
Tyler Veness
2022-05-31 20:21:29 -07:00
committed by GitHub
parent 57428112ac
commit 345cff08c0
2 changed files with 19 additions and 15 deletions

View File

@@ -24,33 +24,33 @@ constexpr empty_array_t empty_array;
template <typename T, size_t N>
class array : public std::array<T, N> {
public:
explicit array(empty_array_t) {}
constexpr explicit array(empty_array_t) {}
template <typename... Ts>
array(T arg, Ts&&... args) // NOLINT
constexpr array(T arg, Ts&&... args) // NOLINT
: std::array<T, N>{std::forward<T>(arg), std::forward<Ts>(args)...} {
static_assert(1 + sizeof...(args) == N, "Dimension mismatch");
}
array(const array<T, N>&) = default;
array& operator=(const array<T, N>&) = default;
array(array<T, N>&&) = default;
array& operator=(array<T, N>&&) = default;
constexpr array(const array<T, N>&) = default;
constexpr array& operator=(const array<T, N>&) = default;
constexpr array(array<T, N>&&) = default;
constexpr array& operator=(array<T, N>&&) = default;
array(const std::array<T, N>& rhs) { // NOLINT
constexpr array(const std::array<T, N>& rhs) { // NOLINT
*static_cast<std::array<T, N>*>(this) = rhs;
}
array& operator=(const std::array<T, N>& rhs) {
constexpr array& operator=(const std::array<T, N>& rhs) {
*static_cast<std::array<T, N>*>(this) = rhs;
return *this;
}
array(std::array<T, N>&& rhs) { // NOLINT
constexpr array(std::array<T, N>&& rhs) { // NOLINT
*static_cast<std::array<T, N>*>(this) = rhs;
}
array& operator=(std::array<T, N>&& rhs) {
constexpr array& operator=(std::array<T, N>&& rhs) {
*static_cast<std::array<T, N>*>(this) = rhs;
return *this;
}