V
Vladimir Petter
Hello,
I am not sure if this bug was noticed before so please ignore posting if it
was.
I was playing with sample from "C++ Templates The Complete Guide" chapter
8.2.4
#include <iostream>
using namespace std;
template <typename T1, typename T2, typename T3=int>
class C;
template <typename T1, typename T2=char, typename T3>
class C;
template <typename T1=long, typename T2, typename T3>
class C{};
void main(){
C<long> c;
cout << typeid(c).name() << endl;
}
Gives following output:
class C<long,long,int>
Expected output was
class C<long,char,int>
If we modify template definition by removing default value for T1:
template <typename T1, typename T2, typename T3>
class C{};
then output is back to normal
Second part of issue is that if all class template arguments have default
values (same sample that gives wrong output) I can not instantiate class
using "C<>". Compiler gives an error that I provided too few parameters.
Of cause this is a minor bug, because I do not see practical reasons to
spread around default values among multiply definitions, but who knows may
be somebody does
Regards,
Vladimir.
I am not sure if this bug was noticed before so please ignore posting if it
was.
I was playing with sample from "C++ Templates The Complete Guide" chapter
8.2.4
#include <iostream>
using namespace std;
template <typename T1, typename T2, typename T3=int>
class C;
template <typename T1, typename T2=char, typename T3>
class C;
template <typename T1=long, typename T2, typename T3>
class C{};
void main(){
C<long> c;
cout << typeid(c).name() << endl;
}
Gives following output:
class C<long,long,int>
Expected output was
class C<long,char,int>
If we modify template definition by removing default value for T1:
template <typename T1, typename T2, typename T3>
class C{};
then output is back to normal
Second part of issue is that if all class template arguments have default
values (same sample that gives wrong output) I can not instantiate class
using "C<>". Compiler gives an error that I provided too few parameters.
Of cause this is a minor bug, because I do not see practical reasons to
spread around default values among multiply definitions, but who knows may
be somebody does
Regards,
Vladimir.