G
Guest
Personally, I like to use simple abstractions to wrap resources
For example consider a class that wraps a resource - say an IntPtr which is allocated in the constructor and deallocated in the destructor.
In the managed world I find that I can not use this because destructors (and copy constructors) for value types are not allowed. Of all the restrictions when compiling managed C++ code (and there are many!) this one is one of my pet hates
To me this was quite unexpected
I do not want to allocate the class as a object on the managed heap (__gc) because that would either require explicit calling of Dispose - which defeats the purpose of the abstraction or waiting for gc - which is not what I want to do either
Are there any ways round this?
For example consider a class that wraps a resource - say an IntPtr which is allocated in the constructor and deallocated in the destructor.
In the managed world I find that I can not use this because destructors (and copy constructors) for value types are not allowed. Of all the restrictions when compiling managed C++ code (and there are many!) this one is one of my pet hates
To me this was quite unexpected
I do not want to allocate the class as a object on the managed heap (__gc) because that would either require explicit calling of Dispose - which defeats the purpose of the abstraction or waiting for gc - which is not what I want to do either
Are there any ways round this?