mercredi 5 avril 2017

what's the mean of just a typename in template parameter list?

template <typename Method, typename>
struct is_default : std::false_type { };

and what's the difference between the code above and this:

struct default_ { };
template <typename Method>
struct is_default<Method, decltype((void)
    static_cast<default_>(*(Method*)0)
)>
    : std::true_type
{ };

I can figure out that the last one is used to identify whether the Method is default. But I cannnot understand the use of decltype((void)static_cast<default_>((Method*)0)) , how does it work, and how it make the second code block different from the first code block? And what's the mean of just a typename in template parameter list like this template <typename Method, typename>?

Aucun commentaire:

Enregistrer un commentaire