I came across this great article: http://ift.tt/1HCy8ob
In the following code :
template<class A, template<class...> class B> struct mp_rename_impl;
template<template<class...> class C, class... T, template<class...> class B>
struct mp_rename_impl<C<T...>, B>
{
using type = B<T...>;
};
template<class A, template<class...> class B>
using mp_rename = typename mp_rename_impl<A, B>::type;
//...
mp_rename<mp_list<int, float, void*>, std::tuple>; // -> std::tuple<int, float, void*>
// T... will be deduced as int, float, void*
Why C is deduced as mp_list (instead of mp_list< int, float, void* >) and T... as int, float, void* ?
I think the trick is the template specialization part : struct mp_rename_impl< C < T... >, B>, But I struggle to understand why
Aucun commentaire:
Enregistrer un commentaire