
19 Jan
2020
19 Jan
'20
10:56 a.m.
Hi I ran the following code: const std::string i = "some string"; boost::optional<const std::string&> str = i; cout << get_optional_value_or(str, "some other string") ; It gives the output as : some string Which is absolutely fine. But when I run const std::string i = {}; boost::optional<const std::string&> str = i; cout << get_optional_value_or(str, "some other string") ; The output is an empty string. Shouldn't it give "some other string as output" because if I run the same code with integer it gives the second parameter of get_optional_value_or() as output?