Copy Control with boost::shared_array

This is a discussion on Copy Control with boost::shared_array within the C++ Programming forums, part of the General Programming Boards category; When using boost::shared_array as a data member, I'm ok without declaring my own copy constructor and assign operator just like ...

  1. #1
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,456

    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.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    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,317
    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,893
    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
    Portugal
    Posts
    7,456
    Most excellent. Thanks.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    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, 01: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, 06:58 AM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 11:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21