This is the mail archive of the gcc@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]

Template argument deduction from reference argument


struct S
{
  virtual void f() = 0;
};

void g(int);

template <typename T>
void f(T t)
{
  g(t);
}

int main()
{
  S &rs = rs;
  f(rs);
}

gcc 2.95.2 says this:

foo.cpp: In function `void f<S>(S)':
foo.cpp: instantiated from here
foo.cpp: `struct S' used where a `int' was expected

Does this mean that
- template argument type S is deduced from actual argument S &?
- an instance (t) of an abstract class is thereby created?

I would have expected T to be bound to S &.

Thomas

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