[Bug c++/23977] fails to resolve templated constructor

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Tue Sep 20 20:07:00 GMT 2005


------- Additional Comments From bangerth at dealii dot org  2005-09-20 20:07 -------
A constructor is a special function the name of which is that of the type 
to which it belongs. The type's name is that that includes template arguments. 
 
You could also say that the constructor is a function that is implicitly 
called upon creation of an object of a certain type. The name of the type 
is what you have to specify. 
 
That the constructor is not just another function is that in this case 
-------------- 
int f(int); 
template <typename T> int f(T); 
-------------- 
you can force the template be called even if the argument is an integer 
by calling f<int>(1). A similar trick doesn't work for constructors: 
-------------- 
struct S { 
  S(int); 
  template <typename T> S(T); 
}; 
 
S s(int);  // no way to get the template constructor called, whatever you do 
-------------- 
 
W. 
 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23977



More information about the Gcc-bugs mailing list