• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Any compiler warning for default copy constructors?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Any compiler warning for default copy constructors? (From: Scott Fraser <email@hidden>)
 >Re: Any compiler warning for default copy constructors? (From: "Clark Cox" <email@hidden>)
 >Re: Any compiler warning for default copy constructors? (From: Steve Baxter <email@hidden>)
 >Re: Any compiler warning for default copy constructors? (From: Paul Walmsley <email@hidden>)

  • Prev by Date: Re: XCode doesn't open anything
  • Next by Date: Re: debugging on Intel macs
  • Previous by thread: Re: Any compiler warning for default copy constructors?
  • Next by thread: Re: Any compiler warning for default copy constructors?
  • Index(es):
    • Date
    • Thread