Overloaded function called from template.

corey taylor corey.taylor@gmail.com
Thu Jan 20 05:24:00 GMT 2005


Hello,

  I am bringing this question from graphics3D development (
http://www.graphics3d.com ).

  I did not want to flood the bug system with an unqualified report,
so if you could help me clarify if this is an issue.

  This happens only with g++ 3.4

  Simply put, calling an overloaded function from a template will fail
with no matching overload IF the overloaded function is declared after
the template.

  In everything up to g++ 3.4, the overloaded function was properly
found when the template was used.  Considering that the template is
typically defined in a header, we don't see why it is expecting
overloaded functions defined before that in 3.4 and never before.

  An example of the code flow:

  void overloadedFunc(const std::string& var) {

  }

  void overloadedFunc(int var) {
  }

--- templated code that calls overloadedFunc with template variable --

  void overloadedFunc(const SpecialClass& var) {
  }

--- Use the templated code with SpecialClass ----


If I can provide better information, or if you think this could be
filed as a bug-report, please reply.

Corey Taylor



More information about the Gcc-help mailing list