TITLE: type signatures for new and delete (Newsgroups: comp.std.c++, 18 Nov 98) ???: rado42@my-dejanews.com >> Does anybody know wthether operator new and operator new[] are >> distingushable in the external scope? I mean, provided I wan't to >> make my own new, should I (or can I) also supply new[]? If so, how >> can it be done? ALLANW: AllanW@my-dejanews.com >Yes, absolutely. You shouldn't have to prototype these functions >if you use the "normal" signatures: > void * operator new[](size_t); > void * operator new(size_t); > void operator delete[](void*); > void operator delete(void*); CLAMAGE: Steve Clamage, stephen.clamage@sun.com But those are not the "normal" signatures, by which I assume you mean the predefined versions that come with the standard library. The standard functions must have throw specifications, and the above declarations will conflict with them. The standard specifies four more versions besides. ALLANW: >If you use other function signatures, you will have to declare >them before use. CLAMAGE: Yes, and they must be "placement forms", since the standard signatures are pre-empted by the standard. You can replace the standard functions with your own versions, but you can't use subtly different versions of the standard signatures and get predictable results. The standard signatures are as follows: // single-object forms void* operator new(size_t size) throw(std::bad_alloc); void* operator new(size_t size, const std::nothrow_t&) throw(); void operator delete(void* ptr) throw(); void operator delete(void* ptr, const std::nothrow_t&) throw(); // array forms void* operator new[](size_t size) throw(std::bad_alloc); void* operator new[](size_t size, const std::nothrow_t&) throw(); void operator delete[](void* ptr) throw(); void operator delete[](void* ptr, const std::nothrow_t&) throw(); The original question was about MSC5, and I don't know whether that particular compiler uses these forms. But since this is comp.STD.c++, I'm discussing the language definition. Questions about a particular version of a particular compiler should be addressed to a newsgroup devoted to that compiler.