2CPXGSD5DDJJQ3LXW5LEW5UJYAQYX3ISVCRIMGDQJ5IQYYPCJNEAC
U4IDI3M3RBNIQIY43PFKMPBHVCKG37FI5ARJ4GOKY7KKCD2DILWAC
YIQN7NJTGEVKW7JZHL6CTH6EPCIXCNBYNURIGXPYZAOUX3VAJQMAC
5UMVJBOXMEKW2H5JG7T4APWP4QSLSPQSXW6RJBZS6FQQ3BG2XXQAC
FEMASUBNU32NSG4DNXZX54CGCA57PVRGYO46L3A6F2EJ4BCSJ3SAC
OHAARXLBTFOIV5FOTY7IDMOIAE275CKXCE6XQMWV3EC63YCSMIWAC
QU4IBVXLLNKNFHT25ZP23INGTVGISDTTLPUBD5S7PCDBC3ZXF3QAC
DTKQAPJB6JCJZYLQ4MOFA5QHDCCIQ3KG5ED6PVF5PGEH33YSJFBAC
namespace {
template <typename T, size_t N, typename... Ts>
/*CCTK_ATTRIBUTE_ALWAYS_INLINE*/
constexpr enable_if_t<(sizeof...(Ts) == N), array<T, N> >
array_from_initializer_list(const T *const beg, const T *const end,
const Ts &... xs) {
return array<T, N>{xs...};
}
// namespace {
// template <typename T, size_t N, typename... Ts>
// /*CCTK_ATTRIBUTE_ALWAYS_INLINE*/
// constexpr enable_if_t<(sizeof...(Ts) == N), array<T, N> >
// array_from_initializer_list(const T *const beg, const T *const end,
// const Ts &... xs) {
// return array<T, N>{xs...};
// }
//
// template <typename T, size_t N, typename... Ts>
// /*CCTK_ATTRIBUTE_ALWAYS_INLINE*/
// constexpr enable_if_t<(sizeof...(Ts) < N), array<T, N> >
// array_from_initializer_list(const T *const beg, const T *const end,
// const Ts &... xs) {
// return array_from_initializer_list<T, N>(beg + 1, end, xs...,
// beg < end ? *beg : T{});
// }
// } // namespace
//
// template <typename T, size_t N>
// /*CCTK_ATTRIBUTE_ALWAYS_INLINE*/ constexpr array<T, N>
// array_from_initializer_list(initializer_list<T> l) {
// return array_from_initializer_list<T, N>(l.begin(), l.end());
// }
template <typename T, size_t N, typename... Ts>
/*CCTK_ATTRIBUTE_ALWAYS_INLINE*/
constexpr enable_if_t<(sizeof...(Ts) < N), array<T, N> >
array_from_initializer_list(const T *const beg, const T *const end,
const Ts &... xs) {
return array_from_initializer_list<T, N>(beg + 1, end, xs...,
beg < end ? *beg : T{});
// namespace {
// template <typename T, size_t N, typename... Ts>
// /*CCTK_ATTRIBUTE_ALWAYS_INLINE*/
// constexpr enable_if_t<(sizeof...(Ts) == N), array<T, N> >
// array_from_initializer_list(const T *const beg, const T *const end,
// const Ts &... xs) {
// return array<T, N>{xs...};
// }
// template <typename T, size_t N, typename... Ts>
// /*CCTK_ATTRIBUTE_ALWAYS_INLINE*/
// constexpr enable_if_t<(sizeof...(Ts) < N), array<T, N> >
// array_from_initializer_list(const T *const beg, const T *const end,
// const Ts &... xs) {
// return array_from_initializer_list<T, N>(beg, end - 1,
// beg < end ? *(end - 1) : T{},
// xs...);
// }
// } // namespace
//
// template <typename T, size_t N>
// /*CCTK_ATTRIBUTE_ALWAYS_INLINE*/ constexpr array<T, N>
// array_from_initializer_list(initializer_list<T> l) {
// return array_from_initializer_list<T, N>(l.begin(), l.end());
// }
template <typename T, size_t N>
/*CCTK_ATTRIBUTE_ALWAYS_INLINE*/ constexpr enable_if_t<(N == 3), array<T, N> >
array_from_initializer_list(initializer_list<T> l) {
assert(l.size() >= N);
const T *restrict const p = l.begin();
return {p[0], p[1], p[2]};
static_assert(static_cast<const array<int, 3> &>(
array_from_initializer_list<int, 3>({0, 1, 2}))[0] == 0,
"");
static_assert(static_cast<const array<int, 3> &>(
array_from_initializer_list<int, 3>({0, 1, 2}))[1] == 1,
"");
static_assert(static_cast<const array<int, 3> &>(
array_from_initializer_list<int, 3>({0, 1, 2}))[2] == 2,
"");
/*CCTK_ATTRIBUTE_ALWAYS_INLINE*/ constexpr vect(initializer_list<T> arr)
: elts(array_from_initializer_list<T, D>(arr)) {
/*CCTK_ATTRIBUTE_ALWAYS_INLINE*/ constexpr vect(initializer_list<T> lst)
: elts(array_from_initializer_list<T, D>(lst)) {
namespace static_test {
constexpr vect<int, 3> vect1{0, 1, 2};
static_assert(vect1[0] == 0, "");
static_assert(vect1[1] == 1, "");
static_assert(vect1[2] == 2, "");
constexpr vect<vect<int, 3>, 3> vect2{
{100, 101, 102},
{110, 111, 112},
{120, 121, 122},
};
static_assert(vect2[0][0] == 100, "");
static_assert(vect2[0][1] == 101, "");
static_assert(vect2[0][2] == 102, "");
static_assert(vect2[1][0] == 110, "");
static_assert(vect2[1][1] == 111, "");
static_assert(vect2[1][2] == 112, "");
static_assert(vect2[2][0] == 120, "");
static_assert(vect2[2][1] == 121, "");
static_assert(vect2[2][2] == 122, "");
} // namespace static_test