Topic: Overloaded template functions


Author: jamshid@io.com (Jamshid Afshar)
Date: 1996/01/05
Raw View
Hi, folks, long time no see.  I'm just wondering if the standard
actually disallows some code of mine containing overloaded function
templates.  Fortunately (for my code, bad for me) I think this is just
another VC++ 4 bug wrt templates.  Oh well, at least VC++ has improved
to the point that it handles *most* of the stuff I wrote three years
ago under BC++ 3.1.

cl -c bug2.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 10.00.5270 for 80x86
bug2.cpp(16) : error C2668: 'functor' : ambiguous call to overloaded function
(new behavior; please see help)

   template<class O, class R>
void functor(O* object, R (O::*method)());

   template<class O, class R, class P>
void functor(O* object, R (O::*method)(P));

class M {
public:
    int f( char* );
    int g( );
};

int main() {
    M m;
    functor(&m, &M::f);
    functor(&m, &M::g);  // VC++ 4 incorrectly flags this as ambiguous
    return 0;
}
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]