There is something that has been on my mind for a long time now. Just consider this function:
template<typename T>
T foo(const T& value)
{
return value;
}
It’s the simplest possible function wrapper for any given value. However, I’ve been wondering whether it has a “standard name” (that many would recognize, like functions such as map, filter, sqrt, etc…). And are they well-known problems that require to use such a function?
In principle it’s an identity function, but in practice it forces a copy of the argument.
So, if
Thas value semantics, it’s still a real identity.Otherwise, it’s a cloning function.
A perfect identity would be