Class template specialization priority/ambiguity

前端 未结 1 802
南旧
南旧 2021-02-07 07:23

While trying to implement a few things relying on variadic templates, I stumbled accross something I cannot explain. I boiled down the problem to the following code snippet:

1条回答
  •  别跟我提以往
    2021-02-07 08:04

    From temp.class.order:

    For two class template partial specializations, the first is more specialized than the second if, given the following rewrite to two function templates, the first function template is more specialized than the second according to the ordering rules for function templates ([temp.func.order]):

    • Each of the two function templates has the same template parameters as the corresponding partial specialization.

    • Each function template has a single function parameter whose type is a class template specialization where the template arguments are the corresponding template parameters from the function template for each template argument in the template-argument-list of the simple-template-id of the partial specialization.

    The order of:

    template