This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/61636] generic lambda "cannot call member function without object"
- From: "tower120 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 28 Jun 2014 13:17:31 +0000
- Subject: [Bug c++/61636] generic lambda "cannot call member function without object"
- Auto-submitted: auto-generated
- References: <bug-61636-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61636
--- Comment #3 from tower120 <tower120 at gmail dot com> ---
I found that as only I pass *this as parameter and then call functions from it,
it works ok. But it have to be auto:
/// This work
std::cout << if_else(do_first,
*this,
[&](auto self){ return self.fn1(data); },
[&](auto self){ return self.fn2(data); }
) << '\n';
/// This not
std::cout << if_else(do_first,
*this,
[&](Test self){ return self.fn1(data); },
[&](Test self){ return self.fn2(data); }
) << '\n';
http://coliru.stacked-crooked.com/a/272a5e0b8089a5c4
And what even more strange, it work if only one lambda is auto:
std::cout << if_else(do_first,
*this,
[&](auto self){ return self.fn1(data); },
[&](Test self){ return self.fn2(data); } // ???
) << '\n';
http://coliru.stacked-crooked.com/a/ed45a402a6c11d63