Mixing always/const_ and meta::id. Missing meta::identity Callable.
id<T>: A trait that always returns its argument T. Also, a Callable that always returns T.
Other libraries use always<T> or const_<T> for a Callable that always returns T.
Naming id<T> a Callable that doesn't behaves as the identify Callable is disturbing. I believe that id<T> should only be a trait and that we could add an meta::identity Callable
struct identity {
template < class T>
using invoke = T;
};
it can also be defined as
using identity = quote_trait<id>;
What do you think?
Naming id<T> a Callable that doesn't behaves as the identify Callable is disturbing.
I'm not sure understand. What exactly is the problem?
It's a misnomer to say that id<T> is both a trait and a callable; the class template id is a trait, and its specializations are callables. (Yes, Trait is a concept for class templates, not for types.)
Naming id<T> a Callable that doesn't behaves as the identify Callable is disturbing.
Why would someone expect id<double> or id<std::string> to be an identity callable?
It's a misnomer to say that id<T> is both a trait and a callable; the class template id is a trait, and its specializations are callables. (Yes, Trait is a concept for class templates, not for types.)
That is not how meta defines the Trait concept.
For me this is a naming issue. You can of course disagree.
I believe that the identity callable is missing as it is one of the basic Callable operations.
While i was looking for this Callable, I found id but its definition as a Callable is not what I was looking for.
What I'm saying is that if invoke<id<T>, Us...>> is T, it behaves like the constant function T. And that other libraries use for this Callable other names like always or constant.
I pretend that the following is more readable and coveys better the intent
invoke<always<T>, U>>
than
invoke<id<T>, U>>
But maybe you think differently.
What, in your opinion, should invoke<id<T>, U> be?
It's a misnomer to say that id is both a trait and a callable; the class template id is a trait, and its specializations are callables. (Yes, Trait is a concept for class templates, not for types.)
That is not how meta defines the Trait concept.
... which in conflict with how the standard uses the term trait. I should revisit this.
As a sidenote:
I expect: invoke<id<double>, U> to turn into double<U> which does not work of course.
Is this correct?
What, in your opinion, should
invoke<id<T>, U>be?
Compilation fail.
I would expect invoke<always<T>, U> or invoke<constant<T>, U> to be T.