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