|
Boost : |
From: cop_at_[hidden]
Date: 2001-09-28 11:30:27
When using boost::scoped_ptr or boost::scoped_array on MSVC 6.0 SP4
with warning level /W4, I get the following warnings about subclasses
of boost:noncopyable not defining (private) copy constructors and
assignment operator. With default warning level /W3, there are no
warnings. I'm sure the Boost library does not want to become bloated
with fixes for compiler-specific warnings, but I like to compile with
all my compiler's warnings enabled and some small fixes like these
would make that easier. Admittedly, Microsoft's own header files do
not pass MSVC's warning level /W4, but at least we can try. <:-)
Compiling...
foobar.cpp
d:\foobar.cpp(66) : see reference to class template
instantiation 'boost::scoped_ptr<class foobar>' being compiled
d:\boost_1_24_0\boost\smart_ptr.hpp(96) : warning
C4511: 'scoped_ptr<class foobar>' : copy constructor could not be
generated
d:\foobar.cpp(66) : see reference to class template
instantiation 'boost::scoped_ptr<class foobar>' being compiled
d:\boost_1_24_0\boost\smart_ptr.hpp(96) : warning
C4512: 'scoped_ptr<class foobar>' : assignment operator could not be
generated
d:\foobar.cpp(66) : see reference to class template
instantiation 'boost::scoped_ptr<class foobar>' being compiled
d:\boost_1_24_0\boost\smart_ptr.hpp(124) : warning
C4511: 'scoped_array<class foobar>' : copy constructor could not be
generated
d:\foobar.cpp(67) : see reference to class template
instantiation 'boost::scoped_array<class foobar>' being compiled
d:\boost_1_24_0\boost\smart_ptr.hpp(124) : warning
C4512: 'scoped_array<class foobar>' : assignment operator could not
be generated
d:\foobar.cpp(67) : see reference to class template
instantiation 'boost::scoped_array<class foobar>' being compiled
The fix for these warnings is simply to define a private copy
constructor and assignment operator for boost::scoped_ptr and
boost::scoped_array. For example:
private: // noncopyable
scoped_ptr( const scoped_ptr& );
const scoped_ptr& operator=( const scoped_ptr& );
private: // noncopyable
scoped_array( const scoped_array& );
const scoped_array& operator=( const scoped_array& );
thanks,
chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk