tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
extent.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_TYPE_TRAITS_EXTENT_HPP
5#define TETL_TYPE_TRAITS_EXTENT_HPP
6
7#include <etl/_cstddef/size_t.hpp>
8#include <etl/_type_traits/integral_constant.hpp>
9
10namespace etl {
11
12/// \brief If T is an array type, provides the member constant value equal to
13/// the number of elements along the Nth dimension of the array, if N is in [0,
14/// rank_v<T>). For any other type, or if T is an array of unknown bound along
15/// its first dimension and N is 0, value is 0.
16/// \ingroup type_traits
17template <typename T, unsigned N = 0>
18struct extent : integral_constant<size_t, 0> { };
19
20template <typename T>
21struct extent<T[], 0> : integral_constant<size_t, 0> { };
22
23template <typename T, unsigned N>
24struct extent<T[], N> : extent<T, N - 1> { };
25
26template <typename T, size_t I>
27struct extent<T[I], 0> : integral_constant<size_t, I> { };
28
29template <typename T, size_t I, unsigned N>
30struct extent<T[I], N> : extent<T, N - 1> { };
31
32/// \ingroup type_traits
33template <typename T, unsigned N = 0>
34inline constexpr auto extent_v = static_cast<size_t>(extent<T, N>::value);
35
36} // namespace etl
37
38#endif // TETL_TYPE_TRAITS_EXTENT_HPP
constexpr auto extent_v
Definition extent.hpp:34
Definition adjacent_find.hpp:9
If T is an array type, provides the member constant value equal to the number of elements along the N...
Definition extent.hpp:18
Definition integral_constant.hpp:11