online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/** type_of_list<...>::type - helper structure for determining type of the first item in the list */ template<auto ... List> struct type_of_list; template<auto List> struct type_of_list<List> { using type = decltype(List); }; template<auto First, auto ... List > struct type_of_list<First, List...> : type_of_list<First> {}; /** type_of<...>::type - determines type of the first item in the list */ template<auto ... List> using type_of = typename type_of_list<List...>::type; /** any_of<...>(value) - compares value against all template parameters and returns true if any matches */ template<auto ... List> inline constexpr bool any_of(type_of<List...> value) noexcept { return ((value == List) || ...); } #include <iostream> #include <string> enum class num { zero, one, two }; int main() { num v { num::one }; std::cout << any_of<num::zero, num::two>(v) << " " << any_of<num::zero, num::one>(v) << std::endl; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue