Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- operator new with empty exception-specification calling constructor when allocation returns 0
- void * operator new (size_t s, PersistentMemory * m) throw()
- {return m->allocatePersistentMemory(s);}
- void *myalloc (size_t) { return 0; }
- void * operator new (size_t s) throw() { return myalloc(s); }
- struct Foo {
- std::string s;
- Foo () { std::cout << this << std::endl; }
- };
- int main () {
- Foo *f = new Foo;
- if (f == 0) std::cout << "f is NULL" << std::endl;
- }
- void *myalloc (size_t) { return 0; }
- void * operator new (size_t s) throw() { return myalloc(s); }
- struct Foo {
- std::string s;
- Foo () { std::cout << this << std::endl; }
- void * operator new (size_t s) { return myalloc(s); }
- };
- int main () {
- Foo *f = new Foo;
- if (f == 0) std::cout << "f is NULL" << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment