reflect icon indicating copy to clipboard operation
reflect copied to clipboard

Extend usage possibilities for the Maybe type.

Open OlivierNicole opened this issue 10 years ago • 0 comments

I found myself unable to write:

Maybe<int> answer()
{
   return Maybe<int>(42);
}

int main()
{
   maybe_if(answer(), [](int a) {
               std::cout << "Answer: " << a << '\n';
            });
}

This would yield an error with gcc 5.3.0 because answer() is an rvalue. It would be convenient to write it that way though. So I overloaded maybe_if and MaybeIfImpl with const-qualified versions and the code above now compiles.

OlivierNicole avatar Dec 18 '15 15:12 OlivierNicole