#ifndef CK_STATICALLY_INDEXED_ARRAY_HPP #define CK_STATICALLY_INDEXED_ARRAY_HPP #include "functional2.hpp" #include "sequence.hpp" #include "tuple.hpp" namespace ck { namespace detail { template struct tuple_concat; template struct tuple_concat, Tuple> { using type = Tuple; }; template struct StaticallyIndexedArrayImpl { using type = typename tuple_concat::type, typename StaticallyIndexedArrayImpl::type>::type; }; template struct StaticallyIndexedArrayImpl { using type = Tuple<>; }; template struct StaticallyIndexedArrayImpl { using type = Tuple; }; } // namespace detail template using StaticallyIndexedArray = typename detail::StaticallyIndexedArrayImpl::type; template __host__ __device__ constexpr auto make_statically_indexed_array(const X& x, const Xs&... xs) { return StaticallyIndexedArray(x, static_cast(xs)...); } // make empty StaticallyIndexedArray template __host__ __device__ constexpr auto make_statically_indexed_array() { return StaticallyIndexedArray(); } template struct StaticallyIndexedArray_v2 { __host__ __device__ constexpr StaticallyIndexedArray_v2() = default; __host__ __device__ static constexpr index_t Size() { return N; } // read access template __host__ __device__ constexpr const auto& At(Number) const { static_assert(I < N, "wrong! out of range"); return data_[I]; } // write access template __host__ __device__ constexpr auto& At(Number) { static_assert(I < N, "wrong! out of range"); return data_[I]; } // read access template __host__ __device__ constexpr const auto& operator[](Number i) const { return At(i); } // write access template __host__ __device__ constexpr auto& operator()(Number i) { return At(i); } __host__ __device__ static constexpr bool IsStaticBuffer() { return true; } T data_[N]; }; } // namespace ck #endif