https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81211
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #1) > (In reply to Stephen Kell from comment #0) > > (It may also be a bug in libstdc++ that std::function should require this of > > its argument type, although that's not completely bonkers.) > > It's explicitly required by the standard. Oh, you're talking about the argument to the call operator not the argument to the constructor (which is required to be CopyConstructible). If you declare std::function<bool(T)> then obviously it takes a T by value, because that's what the type "bool(T)" means. If you can't pass the type by value, you can't call the function. (In reply to Stephen Kell from comment #0) > Meanwhile, g++ 6 (Debian 6.3.0-18) says basically the same thing. Note really, all supported releases (which 4.9 is not one of) say: /home/jwakely/gcc/6/include/c++/6.3.1/functional:1914:2: note: template argument deduction/substitution failed: /home/jwakely/gcc/6/include/c++/6.3.1/functional:1913:9: error: no type named ‘type’ in ‘class std::result_of<main(int, char**)::<lambda(T)>&(T)>’ typename = _Requires<_Callable<_Functor>, void>> ^~~~~~~~ Because your lambda with a parameter of type T is not callable with an argument of type T. > Naively at least, I'd expect the error trace to reveal something about > trying to copy a T, presumably in some non-viable constructor of > std::function. It tells you the lambda can't be called, which is why the constructor isn't viable.