Thread: Copy Control with boost::shared_array

  1. #1
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446

    Copy Control with boost::shared_array

    When using boost::shared_array as a data member, I'm ok without declaring my own copy constructor and assign operator just like with the other boost smart_ptr implementations. Correct?

    Lint reports this on a class where I use boost::shared_array as per the Effective C++ rules file. I inhibited this message for that particular class because I think Lint doesn't see past the class definition on this type of error and is consequently unaware of shared_array smart pointer capabilities. However, I would rather much prefer your confirmation.

    As a sidenote, I use this shared_array as it is expected. The class constructor initializes it with a call to new. The destructor doesn't try to delete it and there's no copy control defined for this particular class.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    I haven't used shared_array myself, but if nobody else is able to confirm it I'll just say that I agree with your interpretation and would be quite surprised if it didn't copy itself correctly.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Correct, shared_ptr's automatically called copy constructor does the right thing.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Most excellent. Thanks.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to copy a C struct to a C++ class?
    By Ptbamboo in forum C++ Programming
    Replies: 1
    Last Post: 02-21-2009, 02:11 PM
  2. Copying constant amount of data
    By TriKri in forum C++ Programming
    Replies: 16
    Last Post: 07-12-2008, 06:32 AM
  3. (Multiline) Edit Control Limit
    By P4R4N01D in forum Windows Programming
    Replies: 9
    Last Post: 05-17-2008, 11:56 AM
  4. line number on a rich edit control
    By rakan in forum Windows Programming
    Replies: 1
    Last Post: 02-18-2008, 07:58 AM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM