Stack based object

Hi,

is there a way to make it impossible for a type to be allocated in the stack? Or impossible for a type to be allocated in the free store?

how about something like:

struct not_in_heap {
void* operator new(size_t)=delete;
};

Thanks,
Juan
No.

(It's possible to get close, but not without a whole lot of easily-breakable effort. Let the user decide where to allocate the object.*)

* If data management is an issue, your object should maintain that data in the proper place. But the object itself can be allocated anywhere.
Topic archived. No new replies allowed.