You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to be able to use Lazy as parameter for optional.value_or and make it be evaluated only if it is required.
Since the parameter must be implict convertible to T ( must verify is_convertible trait ), it should be good if
explicit operator reference() const;
is changed to
operator reference() const;
This will allow to do things like:
auto getFromFile = []() { std::cout << "File opened: "; return std::make_tuple("Lazy get the value from some file!");};
auto lazy_get_from_file = lazy::Lazy<std::string>( getFromFile );
std::optional<std::string> a= "Code value";
std::optional<std::string> b;
std::cout << "::Not empty optional:: "<< a.value_or( lazy_get_from_file ) << std::endl;
std::cout << "::Empty optional:: " << b.value_or( lazy_get_from_file ) << std::endl;
and get this as output:
::Not empty optional:: Code value
::Empty optional:: File opened: Lazy get the value from some file!
Also bool converter should be removed and implemented as a member function like is_instantiated() in cast T is bool
Thanks
The text was updated successfully, but these errors were encountered:
I'd like to be able to use Lazy as parameter for optional.value_or and make it be evaluated only if it is required.
Since the parameter must be implict convertible to T ( must verify is_convertible trait ), it should be good if
explicit operator reference() const;
is changed to
operator reference() const;
This will allow to do things like:
and get this as output:
Also bool converter should be removed and implemented as a member function like is_instantiated() in cast T is bool
Thanks
The text was updated successfully, but these errors were encountered: