Thread: howto wrap char* in auto_prt

  1. #16
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    >> I think that it has to do with trouble building boost on other platforms with the compilers we have.
    I don't think you need to build boost to use its scoped_array.

  2. #17
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by CornedBee View Post
    Except for the free, which has absolutely no business being there! The memory was allocated with new[]. It must be freed with delete[].
    Are you sure if was allocated with new?
    I've seen C++ code where they tried to "optimize" it by using malloc() & free() for intrinsic data types and only use new & delete for classes.
    I strongly disagree with C++ code that uses malloc() & free(), but unfortunately there's some of it out there.

  3. #18
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by cpjust View Post
    I've seen C++ code where they tried to "optimize" it by using malloc() & free() for intrinsic data types and only use new & delete for classes.
    This sort of attitude is hilarious. The compiler takes C++ code and turns it into machine language. To most programmers, this is a mysterious, almost magical process. The programmer is happy to accept that this magic "just happens" but simultaneously assumes that the compiler is so stupid that using new[] on a built-in type is somehow going to be less efficient than malloc().

    It's like putting infinite trust in something and at the same time implicitly distrusting it. It's a sign that the programmer has no clue what's actually happening, at ANY level.

  4. #19
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    hm, maybe you could use an std::string before rerereinventing the somewhat-squared wheel . What uses has a smart pointer to a char array that a string can not handle ?
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #20
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Quote Originally Posted by cpjust View Post
    Are you sure if was allocated with new?
    Yes. Read the very first post.
    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

  6. #21
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by CornedBee View Post
    Yes. Read the very first post.
    Oops, I guess I read too fast.

  7. #22
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,653
    Quote Originally Posted by nvoigt View Post
    hm, maybe you could use an std::string before rerereinventing the somewhat-squared wheel . What uses has a smart pointer to a char array that a string can not handle ?
    Yes, best use existing solutions for all data-types that exist. But for other types than char, a smart pointer you could be used.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [C#] howto encrypth and decrypth a string value
    By Jelte in forum C# Programming
    Replies: 16
    Last Post: 09-20-2008, 05:29 AM
  2. which design is better to wrap another class instance
    By George2 in forum C++ Programming
    Replies: 7
    Last Post: 04-13-2008, 12:27 AM
  3. Word wrap
    By Orrill in forum C++ Programming
    Replies: 6
    Last Post: 10-14-2005, 02:00 PM
  4. Word Wrap
    By sethjackson in forum Windows Programming
    Replies: 4
    Last Post: 09-21-2005, 04:35 PM
  5. Word Wrap
    By osal in forum Windows Programming
    Replies: 4
    Last Post: 07-02-2004, 11:16 AM