定义:元函数类是指内嵌有名为apply的public 元函数的类。
虽然元函数是模板而非类型,但是元函数类却以一个普通的非模板类将其包覆起来,使其成为一个类型。因为元函数操作和返回的都是类型,所以元函数类也可以被作为参数传递给另一个元函数,而元函数也可以返回一个元函数类。
从而,我们得到了一个plus_f元函数类,将它作为binaryoperation传递给mpl::transform不会导致编译错误:
template <class t, class d1, class d2>
quantity<
t
, typename mpl::transform<d1,d2,plus_f>::type //new dimensions
>
operator*(quantity<t,d1> x, quantity<t,d2> y)
{
typedef typename mpl::transform<d1,d2,plus_f>::type dim;