| 1 | /* |
| 2 | * Copyright (c) 2023 Philippe Proulx <pproulx@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | */ |
| 6 | |
| 7 | #ifndef LTTNG_TYPE_TRAITS_HPP |
| 8 | #define LTTNG_TYPE_TRAITS_HPP |
| 9 | |
| 10 | #include <type_traits> |
| 11 | |
| 12 | namespace lttng { |
| 13 | namespace traits { |
| 14 | |
| 15 | /* |
| 16 | * Provides the member constant `value` equal to: |
| 17 | * |
| 18 | * `T` is in the list of types `Ts`: |
| 19 | * `true` |
| 20 | * |
| 21 | * Otherwise: |
| 22 | * `false` |
| 23 | */ |
| 24 | template <typename T, typename... Ts> |
| 25 | struct is_one_of : std::false_type { |
| 26 | }; |
| 27 | |
| 28 | template <typename T, typename... Ts> |
| 29 | struct is_one_of<T, T, Ts...> : std::true_type { |
| 30 | }; |
| 31 | |
| 32 | template <typename T, typename U, typename... Ts> |
| 33 | struct is_one_of<T, U, Ts...> : is_one_of<T, Ts...> { |
| 34 | }; |
| 35 | } /* namespace traits */ |
| 36 | } /* namespace lttng */ |
| 37 | |
| 38 | #endif /* LTTNG_TYPE_TRAITS_HPP */ |