lundi 19 mars 2018

How has std::rank been implemented?

I had a look at this archive post

Implementing std::rank for other containers

But it is still unclear to me how the logic of std::rank implementation works.

When I refer to the following

std::rank

I see the following under Possible Implementation

template<class T>
struct rank : public std::integral_constant<std::size_t, 0> {};

template<class T>
struct rank<T[]> : public std::integral_constant<std::size_t, rank<T>::value + 1> {};

template<class T, std::size_t N>
struct rank<T[N]> : public std::integral_constant<std::size_t, rank<T>::value + 1> {};

Could anyone provide a simple explanation about how the above implementation logic works? (does it use variadic templates at all?)

Aucun commentaire:

Enregistrer un commentaire