This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]