AnsiString versus char *

This is a discussion on AnsiString versus char * within the C++ Programming forums, part of the General Programming Boards category; My concern isn't so much with speed. I have always disliked the stl and while some of it is from ...

  1. #31
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    My concern isn't so much with speed. I have always disliked the stl and while some of it is from heresay (memory leaks, bloat, inefficiency, unecessary complication, etc...), mostly it has to do with my stubborness, and desire to write my own code. Hell, if I had it my way, I'd be using a class I developed to generate pure bytecode (...all in good time...)
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  2. #32
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >And we all know I have plenty of that!
    Indeed, but from what I've seen it's mostly well placed.

    >Save for a small handful of functions, yes, yes, and yes.
    Talking about a string class, a small handful of functions could very easily be the entire implementation. I would very much like to see the source for your class including all of the details if you're willing to share. My email is always open.

    >Sure, just give me an example of what sort of algorithm you are referring to.
    I wasn't referring to the string class specifically, but merge would be a good start.

    >[by the way, would you mind supplying me with the code to do that using an std::string? ]
    I'd be glad to:
    Code:
    void find_and_replace ( std::string& s, std::string& to_find, char *rep )
    {
      std::string::size_type pos;
      std::string::size_type len = to_find.length();
    
      while ( ( pos = s.find ( to_find ) ) != std::string::npos )
        s.replace ( pos, len, rep );
    }
    The reason there isn't a find and replace member function for the string class is because it is so easy to write using existing member functions. I think std::string is poorly designed and is a bad example of the STL, but it serves its purpose quite nicely.

    >I have always disliked the stl and while some of it is from heresay (memory leaks, bloat, inefficiency, unecessary complication, etc...)
    All of which are solely based on the fact that the STL implementations are still in their infancy. If this were the best it got then my opinion would be the same as yours.

    >mostly it has to do with my stubborness, and desire to write my own code
    I love getting my hands dirty in the low level areas too, but to not make use of higher level tools when the situation warrants it is foolish.

    -Prelude
    My best code is written with the delete key.

  3. #33
    Registered User
    Join Date
    Apr 2002
    Posts
    23
    Does the '16 lines of code a day' fact not also include design, testing and distribution time.

    Statistics are dodgy.

    Brif

  4. #34
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by brif

    Statistics are dodgy.

    Brif
    88.2 percent of all statistics are made up on the spot - Vic Reeves

  5. #35
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Originally posted by Prelude
    >
    Code:
    void find_and_replace ( std::string& s, std::string& to_find, char *rep )
    {
      std::string::size_type pos;
      std::string::size_type len = to_find.length();
    
      while ( ( pos = s.find ( to_find ) ) != std::string::npos )
        s.replace ( pos, len, rep );
    }
    -Prelude
    This is nice clean code. I like it. The STL is worth using if you take the time to research the STL types and their methods, as well as the global algorithms of the STL. There is nothing worse than non intuitive code in my opinion.

  6. #36
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    And after saying that, I believe that it is still possible to make a mess using the STL, so you have to be careful.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. Conversion Char To Char * Problem
    By ltanusaputra in forum Windows Programming
    Replies: 3
    Last Post: 03-01-2008, 01:06 PM
  3. Wierd Segmentation Faults on Global Variable
    By cbranje in forum C Programming
    Replies: 6
    Last Post: 02-19-2005, 11:25 AM
  4. I'm having a problem with data files.
    By OmniMirror in forum C Programming
    Replies: 4
    Last Post: 05-14-2003, 09:40 PM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM

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