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
14/// \ingroup mpl
15/// @{
16
17template <typename Needle, typename Haystack>
18struct count;
19
20template <typename Needle, typename... Ts>
21struct count<Needle, list<Ts...>> : etl::integral_constant<etl::size_t, (etl::is_same_v<Needle, Ts> + ... + 0)> { };
22
23template <typename Needle, typename Haystack>
24inline constexpr auto count_v = count<Needle, Haystack>::value;
25
26/// @}
27
28} // namespace etl::mpl
29
30#endif // TETL_MPL_COUNT_HPP
Definition at.hpp:10
constexpr auto count_v
Definition count.hpp:24
Definition adjacent_find.hpp:9
Definition integral_constant.hpp:11
Definition list.hpp:11