
Am 19.08.2012 18:54, schrieb Boris Schaeling:
On Sun, 19 Aug 2012 12:46:12 +0200, Klaim - Joël Lamotte <mjklaim@gmail.com> wrote:
[...]Also as pointed by others, it goes agains RAII based design to force the user to explicitely release resources.
I don't think of the child class has a RAII type (but I see how this made you propose a non-copyable class). It could be a RAII type on Windows as the process and thread handles (which are member variables of the class) have to be closed. But it wouldn't work on POSIX as you have to clean up differently. So I treat the child class as a value-based type which works on Windows and POSIX. I'd also prefer a guaranteed cleanup. But it's not clear how to do this with a RAII type on POSIX (unless you have an idea? :).
I would expect from 'modern' C++ that RAII is heavily used - and a process is a system resource. I would find it a little bit odd if a process is value-base. What happened if I copy a child class and invalidate one of the copies. I suggest to make the process moveable-only. The default ctor represents an 'invalid' process class - testable by child::operator <unspecified_bool >() and child::operator!(). child::discard() could move-away the internal representation so that the child instance becomes 'invalid' after this function. Oliver