Is there an established idiom for composing ("chaining") meta-functions? This is my current solution:
template
<
template <typename> class First,
temp开发者_JAVA百科late <typename> class Then,
typename T
>
struct compose : Then<typename First<T>::type> {};
And here is an example usage:
template <typename T>
struct remove_cv : compose<remove_const, remove_volatile, T> {};
Is there a better way to do it?
You might check out the boost::mpl library:
http://www.boost.org/doc/libs/1_46_0/libs/mpl/doc/refmanual/composition-and-argument-binding.html
I'm not claiming that mpl is better than what you have. Just that it looks like similar territory and it might interest you.
精彩评论