https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66135
Bug ID: 66135 Summary: trailing return type generic lambda Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- Consider this attempt at implementing fmap for optionals in C++: #include <boost/optional.hpp> #include <iostream> template <typename Func> auto fmap(Func f) { return [=](auto arg) -> boost::optional<decltype(f(*arg))> { // ** if (arg) { return f(*arg); } else { return boost::none; } }; } int main() { auto id = fmap([](int i){ return i; }); auto res = id(boost::optional<int>{42}); std::cout << *res << std::endl; } This code compiles in clang 3.6, but on gcc 5.1 issues an error on the indicated line: error: invalid type argument of unary '*' (have 'auto:1')