GCC 9.2, partial specialization with non-type template parameters: bug or not?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear list members,

I'd like to ask for your help with the following: in GCC 9.2., is partial
template specialization expected to work for *all* allowed non-type
template parameters of class type?

For a concrete example, please see the code below: it prints "false, true",
i.e., apparently, specializing T for X< Int > does not succeed, whereas it
does for Y< int >. Since Int is now (in C++20) allowed to be used as the
type of non-type template parameters, one would naively expect the
specialization of T for X< Int > to succeed just like the one for Y< int >
does. Is this belief justified, or am I missing something?

Disclaimer: I do realize that C++20 support in GCC 9 is experimental - I'm
just looking for clarity regarding this issue, i.e., does the C++20 (draft)
standard require that the code below print "true, true"?

Best regards,
Bence Kodaj
-------------
- Compiler version (from g++ -v): gcc version 9.2.1 20191102 (Ubuntu
9.2.1-17ubuntu1~18.04.1)
- Compilation command: g++ -std=c++2a main.cpp

- Code:
#include <iostream>
#include <type_traits>

struct Int {
    constexpr Int(int v): value{ v } {}
    const int value;
};

template< Int i >
struct X {};

template< int i >
struct Y {};

template< typename >
struct T : std::false_type {};

template< Int i >
struct T< X< i > > : std::true_type {};

template< int i >
struct T< Y< i > > : std::true_type {};

int main()
{
    std::cout << std::boolalpha << T< X< 123 > >::value << ", " << T< Y<
123 > >::value << "\n";
    return 0;
}



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux