I'm currently writting a metafunction to evaluate expressions, something like boost::mpl::apply:
template<typename EXPRESSION , typename... ARGS>
using eval = typename eval_impl<EXPRESSION,ARGS...>::result;
As you can see, I'm using C++11 template aliases to avoid writting typename ::result
when using the evaluator.
Among other specializations, eval_impl
(The implementation of the evaluation metafunction) has an specializationfor the case the user passes a parametrized expression (Such as a metafunction) and a set of parameters. In other words, for using eval
as a high-order metafunction to evaluate a metafunction with a set of specified parameters.
For that case, I have written a specialization as follows:
template<template<typename...> class F , typename... PLACEHOLDERS , typename... ARGS>
struct eval_impl<F<PLACEHOLDERS...>,ARGS...> : public F<ARGS...> {}
Now consider a use case:
template<typename ARG , typename... ARGS> using first_of = ARG;
using call = eval<first_of<_1,_2,_3,_4> , bool,float,char,int>;
Here we define a custom metafunction first_of
as a template alias, and we pass it to eval
together with a set of parameters to be called (evaluated) with. _1
, _2
... are just placeholders.
I have expected that eval
call instances the specialization defined above, but it doesn't.
And if the aliased type is not a type itself, but a one-parameter template, GCC 4.8.1 says:
Error: Expected one template parameter, two provided
At the point of instantation of that eval_impl
specialization.
So that errors give me to think that the template alias is not taken in the template template parameter of the partial specialization, the aliased type is matched instead.
As you can see in the examples, thats not what I wan't, I need the template alias to be matched as any other metafunction. Is there any way to achieve that?