Boost logo

Boost :

From: Jason Hise (chaos_at_[hidden])
Date: 2005-07-28 16:25:46


Michael Goldshteyn wrote:

>What is:
>
>namespace boost
>{
> const class
> {
>
>???
>
It worked with VC, but I just checked it with comeau and it failed to
compile. To fix it, I had to provide a name for the class and an
explicit default constructor. Naming the class null works, because then
the class name is hidden by the global variable name and thus other
instances of type null cannot be declared. Updated code:

namespace boost
{
    const class null
    {
    private:
        void operator & ( ) const;

    public:
        null ( ) { }

        #ifndef BOOST_NO_MEMBER_TEMPLATES

        // provide conversion to any pointer type
        template < typename Class, typename Type >
        operator Type Class::* ( ) const { return 0; }

        template < typename Type >
        operator Type * ( ) const { return 0; }

        #else

        //provide conversion to int if member templates are not supported
        operator int ( ) const { return 0; }

        #endif//BOOST_NO_MEMBER_TEMPLATES

    } null;
}

#undef NULL
#define NULL (::boost::null)

-Jason


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