Re: Any compiler warning for default copy constructors?
Re: Any compiler warning for default copy constructors?
- Subject: Re: Any compiler warning for default copy constructors?
- From: Howard Hinnant <email@hidden>
- Date: Thu, 23 Feb 2006 09:39:23 -0500
On Feb 23, 2006, at 7:31 AM, Paul Walmsley wrote:
I find boost's 'Non-Copyable' idiom very useful in this case --
either include <boost/utility.hpp> (if you have boost installed
already), or roll your own:
class noncopyable
{
protected:
noncopyable(){}
~noncopyable(){}
private: noncopyable( const noncopyable&);
const noncopyable& operator=( const noncopyable& );
};
Then if you have a class that you want to prevent being copied then
declare it like this:
class myclass : noncopyable // or boost::noncopyable
{
...
};
If you roll your own, be aware of the ADL namespace rules that can
bite you. Whatever namespace your noncopyable is defined in will be
included during unqualified name lookup. This one even bit the guys
at boost, but they've since corrected it by putting the actual
noncopyable implementation into its own unique namespace that no
other type or function shares.
-Howard
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden