7template<
typename... CallbackTypes>
10 using CallbackTypes::operator()...;
14template<
typename... CallbackTypes>
19 auto handle_int = [](
int value)
24 auto handle_double = [](
double value)
29 auto handle_const_char = [](
const char* name)
34 auto catch_all = [](
auto value)
36 stream <<
"Unclassified value: " << value <<
endl;
40 handle_double, handle_const_char, catch_all };
44 handle_callbacks(22.0/7.0);
46 handle_callbacks(
"Thomas Kim");
48 handle_callbacks( std::string(
"Unclassified") );
54 using variant_t = std::variant<int, double, const char*>;
58 auto handle_int = [](
int value)
63 auto handle_double = [](
double value)
68 auto handle_const_char = [](
const char* name)
73 auto catch_all = [](
auto value)
75 stream <<
"Unclassified value: " << value <<
endl;
79 handle_double, handle_const_char, catch_all };
83 auto handle_variant = [&handle_callbacks](
auto& v)
callbacks(CallbackTypes...) -> callbacks< CallbackTypes... >
enable_if_variant_t< VariantType > visit(VisitorType &&visitor, VariantType &&vt)
Stream output operators << are implemented.