Conflict override default template argument

I understand ( here is one source) that you can override the default template arguments if the two definitions do not conflict. So, I am trying to compile the following with g ++ 5.3.1:

template <class = int> class A; // forward declaration
template <class T = A<>> struct B {};

template <class T = int> class A {}; // "= int" here is for clarity

int main() { return 0; }

The compiler complains:

error: overriding default argument for class T

Where is my understanding wrong?

+4
source share
1 answer

You cannot override the default template settings.

template <class T = int> class A {};, , . , ( , ).

+3

Source: https://habr.com/ru/post/1648258/


All Articles