Open TartanLlama opened 6 years ago
Thanks for the report, I will look into this. Using automatic return type deduction would prevent SFINAE-friendliness... I wonder if there's a way of solving this without resorting to that.
I think it's a something of a fundamental issue with making SFINAE friendly wrappers for non-SFINAE friendly callables :disappointed:
You can fob it off on the user and make them give their lambdas return types, but it's not a great solution.
See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0826r0.html for some discussion.
I didn't find a better solution then just having separate versions for C++14 and 11, but if you do I'd love to hear it so that I can steal it for my impl :laughing:
Adding this code to
optional_monadic.cpp
:results in this compiler error on GCC 7.2:
Expected behaviour: compile and run
This is because the implementation of
map
uses trailing return types, even in C++14 mode, which will cause the body of the lambda to be instantiated for the const-qualified overload, giving a hard error (it won't SFINAE).and_then
has a similar issue. This could be solved by using auto return type deduction when compiling in C++14 mode.It took me ages to work out why this broke for my implementation :laughing: