This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/66135] New: trailing return type generic lambda
- From: "barry.revzin at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 13 May 2015 13:56:25 +0000
- Subject: [Bug c++/66135] New: trailing return type generic lambda
- Auto-submitted: auto-generated
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')