TartanLlama / optional

C++11/14/17 std::optional with functional-style extensions and reference support
https://tl.tartanllama.xyz
Creative Commons Zero v1.0 Universal
859 stars 67 forks source link

and_then does not propagate const and ref qualifiers properly #2

Closed TartanLlama closed 7 years ago

TartanLlama commented 7 years ago
  struct overloaded {                                                                                     
    tl::optional<int> operator()(foo &) { return 0; }                                                     
    tl::optional<std::string> operator()(const foo &) { return ""; }                                      
  };                                                                                                      

  tl::optional<foo> f = foo{};                                                                          
  auto x = f.and_then(overloaded{});