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.
16template <typename T, unsigned N = 0>
17struct extent : integral_constant<size_t, 0> { };
18
19template <typename T>
20struct extent<T[], 0> : integral_constant<size_t, 0> { };
21
22template <typename T, unsigned N>
23struct extent<T[], N> : extent<T, N - 1> { };
24
25template <typename T, size_t I>
26struct extent<T[I], 0> : integral_constant<size_t, I> { };
27
28template <typename T, size_t I, unsigned N>
29struct extent<T[I], N> : extent<T, N - 1> { };
30
31template <typename T, unsigned N = 0>
32inline constexpr auto extent_v = static_cast<size_t>(extent<T, N>::value);
33
34} // namespace etl
35
36#endif // TETL_TYPE_TRAITS_EXTENT_HPP
Definition adjacent_find.hpp:9
constexpr auto extent_v
Definition extent.hpp:32
If T is an array type, provides the member constant value equal to the number of elements along the N...
Definition extent.hpp:17
Definition integral_constant.hpp:10