This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/23977] fails to resolve templated constructor
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Sep 2005 20:07:06 -0000
- Subject: [Bug c++/23977] fails to resolve templated constructor
- References: <20050920121043.23977.igodard@pacbell.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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