tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
count.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_COUNT_HPP
5#define TETL_MPL_COUNT_HPP
6
7#include <etl/_cstddef/size_t.hpp>
8#include <etl/_mpl/list.hpp>
9#include <etl/_type_traits/integral_constant.hpp>
10#include <etl/_type_traits/is_same.hpp>
11
12namespace etl::mpl {
13
14template <typename Needle, typename Haystack>
15struct count;
16
17template <typename Needle, typename... Ts>
18struct count<Needle, list<Ts...>> : etl::integral_constant<etl::size_t, (etl::is_same_v<Needle, Ts> + ... + 0)> { };
19
20template <typename Needle, typename Haystack>
21inline constexpr auto count_v = count<Needle, Haystack>::value;
22
23} // namespace etl::mpl
24
25#endif // TETL_MPL_COUNT_HPP
Definition at.hpp:10
constexpr auto count_v
Definition count.hpp:21
Definition adjacent_find.hpp:9
Definition integral_constant.hpp:10
Definition list.hpp:11