Re: Old Meyers C++ compiler test no longer valid?
On Jul 18, 10:56 pm, litb <Schaub-Johan...@web.de> wrote:
On 17 Jul., 23:26, Russ Bryan <rbryan.nay...@gmail.com> wrote:
const class {
public:
template <class T>
operator T*() const {return 0;}
template <class C, class T>
operator const T C::*() const {return 0;}
} null = {};
This looks wrong to me. Doesn't it say that it's a
"pointer to member of C of type const function taking () const and
returning ..."
That's what I thought at first, too. However, taking another look,
you'll notice that the conversion is NOT to a function. If it was a
pointer to a function it would require another set of parentheses and
matching arguments (and, in my testing, a class template instead of a
member template AND a helper template to provide the typedef). So
what this actually says is "const member of class <anonymous>
converting class <anonymous> to a pointer to a member of C with type
const T." Hence the name of the anonymous class, "null"; the effect
of the class is to null out any pointer it is assigned to.
-- Russ
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]