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

Function main

cpp_17/005_optional_optional.cpp:25–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25int main()
26{
27 std::cout << "create(false) returned "
28 << create(false).value_or("empty") << '\n';
29
30 // optional-returning factory functions are usable as conditions of while and if
31 if (auto str = create2(true)) {
32 std::cout << "create2(true) returned " << *str << '\n';
33 }
34
35 if (auto str = create_ref(true)) {
36 // using get() to access the reference_wrapper's value
37 std::cout << "create_ref(true) returned " << str->get() << '\n';
38 str->get() = "Mothra";
39 std::cout << "modifying it changed it to " << str->get() << '\n';
40 }
41}

Callers

nothing calls this directly

Calls 4

createFunction · 0.70
create2Function · 0.70
create_refFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected