tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
index_of.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2024 Tobias Hienzsch
3
4#ifndef TETL_MPL_INDEX_OF_HPP
5#define TETL_MPL_INDEX_OF_HPP
6
7#include <etl/_cstddef/size_t.hpp>
8#include <etl/_mpl/list.hpp>
9#include <etl/_type_traits/integral_constant.hpp>
10
11namespace etl::mpl {
12
13template <typename T, typename List>
14struct index_of;
15
16template <typename T, typename List>
17inline constexpr auto index_of_v = index_of<T, List>::value;
18
19template <typename Head, typename... Tail>
20struct index_of<Head, list<Head, Tail...>> : etl::integral_constant<etl::size_t, 0> { };
21
22template <typename T, typename Head, typename... Tail>
23struct index_of<T, list<Head, Tail...>> : etl::integral_constant<etl::size_t, index_of_v<T, list<Tail...>> + 1> { };
24
25} // namespace etl::mpl
26
27#endif // TETL_MPL_INDEX_OF_HPP
Definition at.hpp:10
constexpr auto index_of_v
Definition index_of.hpp:17
Definition adjacent_find.hpp:9
Definition integral_constant.hpp:10
Definition list.hpp:11