Old Meyers C++ compiler test no longer valid?
I dug up this compiler test submitted to Digital Mars by Scott Meyers
in 2001. At the time, the claim was that Borland and Comeau were able
to compile this code successfully. I've just tried this code with the
Comeau test compiler and VS2008 SP1 and both of them report errors on
lines 32 and 34.
const class {
public:
template <class T>
operator T*() const {return 0;}
template <class C, class T>
operator T C::*() const {return 0;}
} null = {};
class A {
public:
int f (char, int);
int f (char, double);
void f (const char *) const;
};
class B {};
int main() {
int (A::*pmf)(char, int) = &A::f;
pmf = null;
int (A::*pmf2)(char, double) = &A::f;
pmf2 = null;
void (A::*pmf3)(const char*) const = &A::f;
pmf3 = null; <<< No user-defined operator can perform this
conversion
void (B::*pmf4)() const = null; <<< No user-defined operator can
perform this conversion
}
I was wondering if anyone has some insight about this. Are these
calls actually illegal due to some clarification in the standard, or
has compiler conformance on Comeau regressed?
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]