CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
// C++20 Version
#if __cplusplus > 201703L
#include <concepts>
template <typename T, typename... U>
concept any_of = (std::same_as<T, U> || ...);
template <typename T>
concept int_float_double = any_of<T, int, float, double>;
template <int_float_double T>
auto foo(T arg) -> void
{
std::cout << "foo(" << arg << ")\n";
}
// C++17 Version
#elif __cplusplus > 201402L
#include <type_traits>
template <typename T, typename... U>
struct is_any_of : public std::disjunction<std::is_same<T, U>...> {};
template <typename T, typename... U>
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run