Boost logo

Boost :

From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2020-01-19 12:16:11


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_at_[hidden]> 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

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