Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding value_or_eval() #67

Closed
martinmoene opened this issue Nov 4, 2021 · 0 comments
Closed

Consider adding value_or_eval() #67

martinmoene opened this issue Nov 4, 2021 · 0 comments

Comments

@martinmoene
Copy link
Owner

martinmoene commented Nov 4, 2021

See issue 54 at TartanLlama/optional.

Boost.Optional:

    template <typename F>
    value_type value_or_eval ( F f ) const&
      {
        if (this->is_initialized())
          return get();
        else
          return f();
      }
      
    template <typename F>
    value_type value_or_eval ( F f ) &&
      {
        if (this->is_initialized())
          return boost::move(get());
        else
          return f();
      }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant