Trying to understand partial template specialization with template template parameters

I came across this is_specialization implementation found in several posts on SO:

    //1 default
    template<typename Test, template<typename...> class Ref> 
    struct is_specialization : std::false_type {};

    //2 specialization
    template<template<typename...> class Ref, typename... Args>
    struct is_specialization<Ref<Args...>, Ref>: std::true_type {}; 

I think I understand that, for example:

is_specialization<std::tuple<int, float>, std::variant>::value

matches against 1.

But can't understand why:

is_specialization<std::tuple<int, float>, std::tuple>::value

matches against 2.

Maybe it is because I don't very well understand how the template selection process works.

Which is exactly the process that makes the second example match against 2 if, for the first parameter passed to is_specialization, what is expected is a template (template<typename...> class Ref) and not a template instance?

Thank you very much



Read more here: https://stackoverflow.com/questions/66279769/trying-to-understand-partial-template-specialization-with-template-template-para

Content Attribution

This content was originally published by Oscar at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: