"Jesper Madsen" <ba***@mail.stofanet.dk> writes:
Can I confine overrides of new and delete to certain namesspaces, f.ex. by
just introducing the modfied operator new in namespace GUI?? Or should I
ask, if I declare operator new in a namespace, is it still global operator
new I define??
3.7.3.1/1:
An allocation function shall be a class member function or a global function;
a program is ill-formed if an allocation function is declared in a namespace
scope other than global scope or declared static in global scope.
3.7.3.2/1:
Deallocation functions shall be class member functions or global functions;
a program is ill-formed if deallocation functions are declared in a namespace
scope other than global scope or declared static in global scope.
The closest you can get is by using a common base for your GUI objects. E.g.:
namespace GUI
{
struct Object
{
static void*
operator new (size_t) throw (std::bad_alloc);
static void
operator delete (void*);
// ...
};
class Window : public virtual Object
{
// ...
};
}
hth,
-boris
--
Boris Kolpackov
http://kolpackov.net
3072R/AE084F1D - F608 942F 312E D82E 5B84 0407 C880 290B AE08 4F1D