Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-08-01 15:17:12


Peter Dimov wrote:
> Andrey Semashev wrote:
>> Hello Chris,
>>
>> Tuesday, July 31, 2007, 10:22:51 PM, you wrote:
>>
>>> This was a proposed library implementation of nullptr for c++0x from
>>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1601.pdf
>> Hmm, it seems it doesn't convert to function or member function
>> pointers...
>
> On what modern compiler does it not?

Interesting. I guess the conversion to member pointer also works for
member function pointers on compliant compilers. I notice that the
following program doesn't compile with gcc 3.4 though:

struct nullptr_t
{
   template<typename T>
   operator T*() const { return 0; }

   template<typename T, typename U>
   operator T U::*() const { return 0; }
};

const nullptr_t nullptr = {};

struct A {};

int main()
{
   A *p1 = nullptr;
   void (*p2)() = nullptr;
   int (A::*p3) = nullptr;
   int (A::*p4)() = nullptr;
}

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com
The Astoria Seminar ==> http://www.astoriaseminar.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk