tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
rank.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2021 Tobias Hienzsch
3
4#ifndef TETL_TYPE_TRAITS_RANK_HPP
5#define TETL_TYPE_TRAITS_RANK_HPP
6
7#include <etl/_cstddef/size_t.hpp>
8#include <etl/_type_traits/integral_constant.hpp>
9
10namespace etl {
11
12/// \brief If Type is an array type, provides the member constant value equal to
13/// the number of dimensions of the array. For any other type, value is 0. The
14/// behavior of a program that adds specializations for rank or rank_v is
15/// undefined.
16template <typename T>
17struct rank : integral_constant<size_t, 0> { };
18
19template <typename T>
20struct rank<T[]> : integral_constant<size_t, rank<T>::value + 1> { };
21
22template <typename T, size_t N>
23struct rank<T[N]> : integral_constant<size_t, rank<T>::value + 1> { };
24
25template <typename Type>
26inline constexpr size_t rank_v = rank<Type>::value;
27
28} // namespace etl
29
30#endif // TETL_TYPE_TRAITS_RANK_HPP
Definition adjacent_find.hpp:9
constexpr size_t rank_v
Definition rank.hpp:26
Definition integral_constant.hpp:10
If Type is an array type, provides the member constant value equal to the number of dimensions of the...
Definition rank.hpp:17