VIPRA Documentation
Loading...
Searching...
No Matches
all_of_type.hpp
1#pragma once
2
3#include <tuple>
4#include <type_traits>
5#include <utility>
6#include "vipra/util/get_nth_value.hpp"
7
8namespace VIPRA::Util {
9// NOLINTBEGIN(readability-identifier-naming) utility type
10template <typename... type_ts>
11struct all_of_type {};
12
13template <typename type_t>
14struct all_of_type<type_t> {
15 static constexpr bool value = true;
16};
17
18template <typename check_type_t, typename head_t, typename... tail_ts>
19struct all_of_type<check_type_t, head_t, tail_ts...> {
20 static constexpr bool value =
21 std::is_same_v<check_type_t, head_t> && all_of_type<head_t, tail_ts...>::value;
22};
23
24template <typename check_type_t, typename... type_ts>
25struct all_of_type<check_type_t, std::tuple<type_ts...>> {
26 static constexpr bool value =
27 std::is_same_v<check_type_t, std::tuple_element<0, std::tuple<type_ts...>>> &&
28 all_of_type<std::tuple_element<0, std::tuple<type_ts...>>, type_ts...>::value;
29};
30
36template <typename... type_ts>
37inline constexpr bool all_of_type_v = all_of_type<type_ts...>::value;
38// NOLINTEND(readability-identifier-naming)
39} // namespace VIPRA::Util
Definition all_of_type.hpp:11