Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <array> 7 : #include <cstddef> 8 : #include <type_traits> 9 : 10 : namespace tt { 11 : namespace TypeTraits_detail { 12 : template <typename T, std::size_t N> 13 : std::integral_constant<std::size_t, N> array_size_impl( 14 : const std::array<T, N>& /*array*/); 15 : } // namespace TypeTraits_detail 16 : 17 : /// @{ 18 : /// \ingroup TypeTraitsGroup 19 : /// \brief Get the size of a std::array as a std::integral_constant 20 : /// 21 : /// \details 22 : /// Given a std::array, `Array`, returns a std::integral_constant that has the 23 : /// size of the array as its value 24 : /// 25 : /// \usage 26 : /// For a std::array `T` 27 : /// \code 28 : /// using result = tt::array_size<T>; 29 : /// \endcode 30 : /// 31 : /// \metareturns 32 : /// std::integral_constant<std::size_t> 33 : /// 34 : /// \semantics 35 : /// For a type `T`, 36 : /// \code 37 : /// using tt::array_size<std::array<T, N>> = std::integral_constant<std::size_t, 38 : /// N>; 39 : /// \endcode 40 : /// 41 : /// \example 42 : /// \snippet Test_ArraySize.cpp array_size_example 43 : /// \tparam Array the whose size should be stored in value of array_size 44 : template <typename Array> 45 1 : using array_size = 46 : decltype(TypeTraits_detail::array_size_impl(std::declval<const Array&>())); 47 : /// @} 48 : } // namespace tt