
First and foremost, please respect the rules and stop top-posting https://www.boost.org/community/policy.html#quoting> On Sun, 19 Jan 2020 at 12:59, anshu khare via Boost <boost@lists.boost.org> wrote:
When I run the following code :
int i = {}; boost::optional<int> v = i; cout << get_optional_value_or(v, 1)
I get a compilation error in the third line.
¯\_(ツ)_/¯ my crystal sphere has broken https://godbolt.org/z/u3yUgU #include <boost/optional.hpp> #include <iostream> using namespace std; int main() { { int i = {}; // zero boost::optional<int> v = i; cout << get_optional_value_or(v, 1) << endl; // prints 0 } { int i = {5}; boost::optional<int> v = i; cout << get_optional_value_or(v, 1) << endl; // prints 5 } } Best regards, -- Mateusz Loskot, http://mateusz.loskot.net