#include <functional>
#include <iostream>
using namespace std;
struct Y;
struct X
{
std::function<bool(Y&)> b{[] (auto& y_) { return y_.a; }};
bool a{false};
};
struct Y
{
std::function<bool(X&)> b{[] (auto& x_) { return x_.a; }};
bool a{true};
};
int main()
{
return 0;
}
I2luY2x1ZGUgPGZ1bmN0aW9uYWw+CiNpbmNsdWRlIDxpb3N0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnN0cnVjdCBZOwoKc3RydWN0IFgKewoJc3RkOjpmdW5jdGlvbjxib29sKFkmKT4gYntbXSAoYXV0byYgeV8pIHsgcmV0dXJuIHlfLmE7IH19OwoJCglib29sIGF7ZmFsc2V9Owp9OwoKc3RydWN0IFkKewoJc3RkOjpmdW5jdGlvbjxib29sKFgmKT4gYntbXSAoYXV0byYgeF8pIHsgcmV0dXJuIHhfLmE7IH19OwoJCglib29sIGF7dHJ1ZX07Cn07CgppbnQgbWFpbigpCnsKCXJldHVybiAwOwp9Cgo=
prog.cpp: In instantiation of ‘X::<lambda(auto:1&)> [with auto:1 = Y]’:
/usr/include/c++/6/type_traits:2481:26: required by substitution of ‘template<class _Fn, class ... _Args> static std::__result_of_success<decltype (declval<_Fn>()((declval<_Args>)()...)), std::__invoke_other> std::__result_of_other_impl::_S_test(int) [with _Fn = X::<lambda(auto:1&)>&; _Args = {Y&}]’
/usr/include/c++/6/type_traits:2492:55: required from ‘struct std::__result_of_impl<false, false, X::<lambda(auto:1&)>&, Y&>’
/usr/include/c++/6/type_traits:2496:12: required from ‘class std::result_of<X::<lambda(auto:1&)>&(Y&)>’
/usr/include/c++/6/functional:1913:9: required by substitution of ‘template<class _Functor, class, class> std::function<_Res(_ArgTypes ...)>::function(_Functor) [with _Functor = X::<lambda(auto:1&)>; <template-parameter-1-2> = void; <template-parameter-1-3> = <missing>]’
prog.cpp:9:58: required from here
prog.cpp:9:54: error: invalid use of incomplete type ‘struct Y’
std::function<bool(Y&)> b{[] (auto& y_) { return y_.a; }};
~~~^
prog.cpp:5:8: note: forward declaration of ‘struct Y’
struct Y;
^
prog.cpp:9:58: error: could not convert ‘{<lambda closure object>X::<lambda(auto:1&)>{}}’ from ‘<brace-enclosed initializer list>’ to ‘std::function<bool(Y&)>’
std::function<bool(Y&)> b{[] (auto& y_) { return y_.a; }};
^