Boost logo

Boost :

From: anshu khare (anshukhare1998_at_[hidden])
Date: 2020-01-19 10:56:45


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?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk