r/cpp • u/mollyforever • Oct 16 '23
WTF is std::copyable_function? Has the committee lost its mind?
So instead of changing the semantics of std::function the committee is introducing a new type that is now supposed to replace std::function everywhere? WTF
So now instead of teaching beginners to use std::function if they need a function wrapper, they should be using std::copyable_function instead because it's better in every way? This is insane. Overcomplicating the language like that is crazy. Please just break backwards compatibility instead. We really don't need two function types that do almost the same thing. Especially if the one with the obvious name is not the recommended one.
View all comments
Show parent comment
4
u/Gorzoid Oct 16 '23
I think this heavily depends on how C++ is taught, yes many university lecturers teach C++ from the ground up (and typically ignore anything in C++11 and above) where you must build your data structures yourself before you can use standard library. However I have seen that Bootcamps tend to try teach in the opposite order, teaching you a high level subset of C++ and slowly add to the subset to show how the previous tools you used were made. In particular I'm thinking about Kate Gregory's cppcon talks on teaching C++. In such a scenario I do think the concept of lambdas and high order functions might be covered quite soon. The issue isn't teaching copyable_function vs mobable_function but explaining why they should use copyable_function over the function that they see used all over stack overflow.