MCPcopy Create free account
hub / github.com/0voice/cpp_new_features / main

Function main

cpp_17/006_variant_visit.cpp:11–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9template<class... Ts> overloaded(Ts...)->overloaded<Ts...>;
10
11int main() {
12 std::vector<std::variant<int,long,double,std::string>> vec = { 10, 15l, 1.5, "hello" };
13 for (auto& v : vec) {
14 std::visit(overloaded{
15 [](auto arg) { std::cout << arg << ' '; },
16 [](double arg) { std::cout << std::fixed << arg << ' '; },
17 [](const std::string& arg) { std::cout << std::quoted(arg) << ' '; },
18 }, v);
19 }
20}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected