1 2 3 4 5 6 7 8 9 10 | #include <iostream> #include <vector> int main() { int i; auto ignore = [&]() { return 10; }; std::vector<decltype(ignore)> v; v.push_back([&]() { return 100; }); return 0; } |
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKaW50IG1haW4oKSB7CiAgICAgICAgaW50IGk7CiAgICAgICAgYXV0byBpZ25vcmUgPSBbJl0oKSB7IHJldHVybiAxMDsgfTsKICAgICAgICBzdGQ6OnZlY3RvcjxkZWNsdHlwZShpZ25vcmUpPiB2OwogICAgICAgIHYucHVzaF9iYWNrKFsmXSgpIHsgcmV0dXJuIDEwMDsgfSk7CglyZXR1cm4gMDsKfQ==
prog.cpp: In function 'int main()': prog.cpp:8:42: error: no matching function for call to 'std::vector<main()::<lambda()> >::push_back(main()::<lambda()>)' /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/stl_vector.h:741:7: note: candidates are: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = main()::<lambda()>, _Alloc = std::allocator<main()::<lambda()> >, value_type = main()::<lambda()>] /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/stl_vector.h:754:7: note: void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = main()::<lambda()>, _Alloc = std::allocator<main()::<lambda()> >, value_type = main()::<lambda()>]
-
result: Compilation error (maybe you wish to see an example for C++11)


