Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2000-08-21 18:44:14


Should we have a "nonnewable" class? It is similar to noncopyable, but it
bans new and delete instead. Here's a quick mock-up:

//==========================================================================
namespace boost
{
    //...

    class nonnewable
    {
    protected:
        nonnewable() {}
        ~nonnewable() {} // should this be virtual?

    private:
        void * operator new( std::size_t );
        void operator delete( void *, std::size_t );
        void * operator new[]( std::size_t );
        void operator delete[]( void *, std::size_t );
    };

    //...
}
//==========================================================================

Would this prevent someone from creating an object of this class
dynamically? Which header should this class go into (maybe "utility.hpp")?
Can anyone come up with a better name? I heard that some compilers can't
currently handle the array operators above, should we add a Boost #define to
block those operators, and what should they be called?

-- 

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