Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
is_one_of.hpp
Go to the documentation of this file.
1// Copyright 2024, Toyota Motor Corporation
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_IS_ONE_OF_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_IS_ONE_OF_HPP_
7
8// IWYU pragma: private, include "arene/base/type_traits.hpp"
9// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
10
11#include "arene/base/stdlib_choice/integral_constant.hpp"
12#include "arene/base/stdlib_choice/is_same.hpp"
13#include "arene/base/type_traits/any_of.hpp"
14
15namespace arene {
16namespace base {
17
18/// @brief Query if the type 'T' is one of the list of types 'Ts...'
19///
20/// Evaluates to 'true' if 'T' is a member of the set 'Ts...',
21/// otherwise to 'false'.
22///
23/// @tparam T The type to search for in TL.
24/// @tparam TL The TypeList to search in for T.
25template <typename T, typename... Ts>
26constexpr bool is_one_of_v = any_of_v<std::is_same<T, Ts>::value...>;
27
28/// @brief Query if the type 'T' is one of the list of types 'Ts...'
29///
30/// Inherits from std::true_type if 'T' is a member of the set 'Ts...',
31/// otherwise inherits from std::false_type.
32///
33/// @tparam T The type to search for in TL.
34/// @tparam TL The TypeList to search in for T.
35// parasoft-begin-suppress AUTOSAR-A2_7_3 "False positive: documented"
36template <typename T, typename... Ts>
37class is_one_of : public std::integral_constant<bool, is_one_of_v<T, Ts...>> {};
38// parasoft-end-suppress AUTOSAR-A2_7_3
39
40} // namespace base
41} // namespace arene
42
43#endif // INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_TYPE_TRAITS_IS_ONE_OF_HPP_
Query if the type 'T' is one of the list of types 'Ts...'.
Definition is_one_of.hpp:37
Definition array_exceptions_disabled.cpp:11
constexpr bool is_one_of_v
Query if the type 'T' is one of the list of types 'Ts...'.
Definition is_one_of.hpp:26
Copyright 2026, Toyota Motor Corporation.
Definition array_exceptions_disabled.cpp:10