I would like to write some code like this:
some_container | foo<args...>;
For concreteness, let's say the RHS is foo<2>.
The tricky part is, foo is something that should be automatically instantiated. IOW, I "fail" if foo<2> has to be explicitly instantiated, or if I have to stick () or {} after it.
If the LHS is a class type, I can accomplish this by making foo a function returning a "tag" type, then providing a templated overload of operator|. However, this doesn't work (see Overload operator| for fixed-size arrays? for the code I am currently using) if the LHS is also a pointer type, as is the case if it is a C-style array.
Is there any way in C++11 (i.e. without using C++14 variable templates) to achieve this syntax?
The result of this expression ultimately needs to be :
bar<decltype(some_container), args...>{some_container}
(so e.g. bar<int (&)[N], 2> for LHS int[N] and RHS foo<2>).
Aucun commentaire:
Enregistrer un commentaire