Adam D. Ruppe wrote:
On Thu, Oct 08, 2009 at 04:00:03AM -0500, Chris Nicholson-Sauls wrote:
One consideration is that new(), perhaps, ought not be a static member of
its class at all, but rather a global written along similar lines to tools
such as "to".
Agreed. One benefit here is we can convert old code to it just by find/
replacing new -> new!. We can provide easy freestanding functions
for manual management too.
sed is even better in this case :)
new! - gc
manualNew! - malloc() wrapper
Maybe even convenience structs too:
RAII! - a struct that uses the malloc() wrapper
Well if new is a template, its dead easy to use static ifs to detect if
you're allocating an array, a struct or an object and initialize the
memory appropriately.
The only thing that bugs me is that it makes it very hard to implement
overridable new/delete methods for classes, if not impossible.