On Thu, April 26, 2007 10:09, Leon Mlakar wrote:
Michael Marcin wrote:
That's pretty much what I figured. Also I believe the added inline keyword is redundant as a function defined inside of a class declaration is the same as defining inline after the closing semi-colon of the class correct?
Your interpretation is correct, the inline specifier is redundant here.
The copy constructor argument Richard Hadsell mentioned I hadn't even considered and it is a good argument in its own right.
I would like to strengthen Richard's remarks: The newly proposed class violates the "rule of three", because it define's the d'tor, but forget's to implement copy c'tor and copy-assignment op (which is, as Richard already said, a bad idea here). Astonishingly for an expert...
This really should be emphasized. Having a pointer to dynamically allocated buffer without custom copy constructor/copy assignment?Sooner or later somebody will try to copy it ...
Please read the docs! There is clearly written that this class is derived from noncopyable (boost utility class!!!). The source does not contain the derivation but define private declarations of copy ctor and assignment operator. So there is no way to copy this class. Here some source from scoped_array.hpp take a look at the marked lines: // scoped_array extends scoped_ptr to arrays. Deletion of the array pointed to // is guaranteed, either on destruction of the scoped_array or via an explicit // reset(). Use shared_array or std::vector if your needs are more complex. template<class T> class scoped_array // noncopyable { private: T * ptr; scoped_array(scoped_array const &); // <<<===== private not implemented copy ctor scoped_array & operator=(scoped_array const &); // <<<===== private not implemented assignement operator [...] With Kind Regards, Ovanes Markarian