1

please help to understand below scenario

template<typename T1,typename T2=int> class A;
template<typename T1=int,typename T2> class A;
template<typename T1,typename T2> class A{ } 
// yields to  template<typename T1=int,typename T2=int> compiling fine

but when i use non type template its giving error

 template<typename T1,int i=4> class A;
 template<typename T1=int,int i> class A;
 template<typename T1,int i> class A{ }  // error : redefinition of default parameter 2

is this merging won't work with template type and non-type ??

T.C.
  • 133,968
  • 17
  • 288
  • 421
Jagan Arikuti
  • 365
  • 1
  • 2
  • 11
  • What compiler and which version? – T.C. Sep 07 '15 at 19:28
  • @T.C visual c++ 2013 – Jagan Arikuti Sep 07 '15 at 19:47
  • 3
    This [should](http://stackoverflow.com/a/32414941) and [does](https://ideone.com/mFoK4E) work. Looks like a compiler bug? – Kerrek SB Sep 07 '15 at 19:54
  • @KerrekSB seems to be this feature is not in vc++ 2013 or it may be bug . below code is not working in vc++2013 where as it's working with gc v4.8.3 void fun(int i,float f=2.13); void fun(int i=2,float f); void fun(int i,float f){ cout << " i = " << i < – Jagan Arikuti Sep 07 '15 at 20:28
  • 2
    The issue with default template arguments is present in Visual C++ 2015 as well, so you should report it on [Connect](https://connect.microsoft.com/VisualStudio). The example in your comment above compiles fine in VC++ 2015. – bogdan Sep 07 '15 at 21:12

0 Answers0