This is a top-post reminding people to please not top-post:
https://www.boost.org/community/policy.html#quoting
On Sun, 19 Jan 2020 at 13:02, anshu khare via Boost
However when I run
boost::optional<int> i= 5; cout << get_optional_value_or(i, 7) ;
I get the output as 5.
And when I run
boost::optional<int> i= {}; cout << get_optional_value_or(i, 7) ;
I get the output as 7.
Correct! This is expected behaviour. Now, go back to your previous example and compare with the above. Hint: int i = {}; // zero boost::optional<int> v = i; vs boost::optional<int> i= {}; May I suggest you to read through the documentation of boost::optional as well as https://en.cppreference.com/w/cpp/utility/optional, before you waste more time on experiments to reverse-engineer what the library is supposed to do? Best regards, -- Mateusz Loskot, http://mateusz.loskot.net