On 10.05.2018 17:02,
wyn...@gmail.com wrote:
> Recently I had an idea to reimplement new as a function or template
> using C malloc.
Why would you want to do use malloc for C++ `new`?
> An application example is to implement 'new *this'.
That's not valid C++ syntax.
So, it's not really an example of anything.
> I don't use std-library, most of my codes are 'home-made', only few are
> using std:: things (std::terminate(), std::numeric_limits, <typeinfo> )
> So is it doable?
Yes, you can override the allocation and deallocation functions,
operator new, operator new[], operator delete and operator delete[], in
the global namespace as well as per class.
> Any sugestion will be appreciated.
I would suggest not doing this. ;-)
Cheers!,
- Alf