It looks like this is nothing more than a blooper: plus and minus are even not verbs...
The name themselves are not C++14 originals: C++14 just adds the <void>
specialization, but the typed version and all other <functional>
header stuff exist from C++98 (and even pre-iso), and certain coding convention (functions as verbs, object as substatives interface as adjectives...) were not yet already well established.
What C++14 does is just add one more feature to existing definitions letting existing code to continues to works as is. It simply cannot redefine names.
That said, consider also that the +
sign is not always used across the entire standard library for add: in std::string
s it is concatenation, and std::plus
, if applied to strings, concatenates them. Similarly, the * is often used as a "closure" operation (think to boost::spirit
).
A more proper "from scratch" library will most likely call them neutrally as cross
, dash
, star
and slash
, letting the classes that provides the corresponding operations to give them consistent names in their own context
std::add
orstd::subtract
in any form even exist? – Baldpatestd::plus
andstd::minus
, and they usevoid
as a default argument to get the kind I put up in my gist above. How strange. – Baldpateplus
andminus
, it would actually make more sense to havetimes
anddividedby
, but especially that last one just sounds ridiculous -_- – Vipultimes
has been used and given up by SGI because of a name clash with a Unix function, see the link I posted earlier. – Miyamotos
now - all butnegate
, the black sheep. Much more consistent this way ;) – Miyamototypedef std::plus<> add
typedef std::minus<> subtract
typedef std::multiplies<> multiply
typedef std::divides<> divide
-- ezpz! – Baldpate