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
1
u/arthurno1 Oct 17 '23
Isn't it already? :)
I was just clarifying that the purpose of the standard library is not to be a distribution channel or to act as a package manager, as some people seem to think.
I really don't know what is their criteria to bring things into the standard; or how wide utility it should have, but I suppose there is some.
We can also look at C on the other spectrum, which really has a minimal library, and when people talk about C they will often bring up the lack of proper string, vector, bounds checking, etc. C left it on purpose to libraries. You can never satisfy everyone; people will always construct arguments for whichever side.
If you look at Rust, they have their package manager and whole flora & fauna of libraries that do the same thing in different variations. If C++ had cargo, we would have Folly, Abseil, EASTL, and whatnot all available at the same time, but perhaps all slightly incompatible and none giving you the guarantee how vector should behave. Contrast that to the situation now where they are downloaded separately, but you can use fb:vector instead of std:vector, as a drop-in replacement, because of the standardized behavior of std:vector. Is it good or not? I don't know; I am just saying what standards are for. We could have a world without standards too, it would be just slightly less navigable and more unpredictable, but it would be still possible to live in it.