C++ `模板<;自动>;`和部分类模板专门化排序

C++ `模板<;自动>;`和部分类模板专门化排序,c++,templates,language-lawyer,partial-specialization,c++17,C++,Templates,Language Lawyer,Partial Specialization,C++17,考虑: #include <type_traits> template <typename> struct Tag {}; template <typename T> auto tag = Tag<T>{}; template <typename...> struct SelectorImpl; // 1 template <auto... xs> struct SelectorImpl<std::integ

考虑:

#include <type_traits>

template <typename>
struct Tag {};

template <typename T>
auto tag = Tag<T>{};


template <typename...>
struct SelectorImpl;

// 1
template <auto... xs>
struct SelectorImpl<std::integral_constant<decltype(xs), xs>...>
{};

// 2
template <typename T, Tag<T>* tag, auto... xs>
struct SelectorImpl<std::integral_constant<decltype(tag), tag>,
                    std::integral_constant<decltype(xs), xs>...>
{};


template <auto... params>
struct Selector
: SelectorImpl<std::integral_constant<decltype(params), params>...>
{};


int main() {
    Selector<&tag<int>, 1, 2>{};
}
#包括
模板
结构标记{};
模板
自动标记=标记{};
模板
结构选择器mpl;
// 1

模板?这是一个bug吗?

首先,我想确定
的优先级高于


decltype(tag)
看起来可疑。这是不是作为一个bug报告给了gcc/clang开发人员?不知道,我不记得报告过
template<auto...>
struct TestSingleImpl;

// 1
template<auto x>
struct TestSingleImpl<x> { static constexpr bool value = false; };

// 2
template<char x>
struct TestSingleImpl<x> { static constexpr bool value = true; };

static_assert(TestSingleImpl<1234>::value == false, "1");
static_assert(TestSingleImpl<'a'>::value == true, "2");
template <typename...>
struct Test;

// 1
template<auto v, auto... x>
struct Test<std::integral_constant<decltype(v), v>,
            std::integral_constant<decltype(x), x>...>
{
    static constexpr bool value = true;
};

// 2
template<char v, auto... x>
struct Test<std::integral_constant<char, v>,
            std::integral_constant<decltype(x), x>...>
{
    static constexpr bool value = false;
};

template <auto... params>
struct Selector : Test<std::integral_constant<decltype(params), params>...> {};

static_assert(Selector<1234, 1, 2>::value == true, "1"); // 1 - ok
static_assert(Selector<'a', 1, 2>::value == false, "2"); // 2 - AMBIGUITY
template <auto...>
struct Test;

// 1
template<auto v, auto... x>
struct Test<v, x...>
{
    static constexpr bool value = true;
};

// 2
template<char v, auto... x>
struct Test<v, x...>
{
    static constexpr bool value = false;
};

static_assert(Test<1234, 1, 2>::value == true, "1"); // 1 - ok
static_assert(Test<'a', 1, 2>::value == false, "2"); // 2 - ok