Re: String enhancement

Discussion in 'C++' started by Ivan Vecerina, Jul 7, 2003.

  1. "Michael A." <> wrote in message
    news:3rhOa.43917$...
    > How can I enhance the standard c++ string (from #include <string>) so that
    > before it allocates new memory it fills the previous memory with 0's.


    You could do this portably by providing a custom allocator.
    However, you would need to replace std::string (which
    is actually a typedef to std::basic_string<char>) with
    another typedef (e.g. MyString).
    For example:
    typedef std::basic_string<char, std::char_traits<char>
    , MyAllocator<char> > MyString;

    Regarding how to define MyAllocator, you could start with
    either of the following examples:
    http://www.tempest-sw.com/cpp/draft/ch13-36-memory.html
    or
    http://www.roguewave.com/support/docs/leif/toolsug/12-6.html


    std::string itself cannot be altered portably. Except by
    providing your own implementation of the global new and
    delete functions (but this would affect all memory
    allocations, not just strings).


    hth,
    Ivan


    --
    Ivan Vecerina, Dr. med. <> http://www.post1.com/~ivec
    Brainbench MVP for C++ <> http://www.brainbench.com
     
    Ivan Vecerina, Jul 7, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marlene

    Re: asp.net calendar enhancement

    Marlene, Jun 25, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    967
    Marlene
    Jun 25, 2003
  2. Fred.

    Re: asp.net calendar enhancement

    Fred., Jun 25, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    3,799
  3. randau
    Replies:
    30
    Views:
    1,427
    Travis Newbury
    May 20, 2005
  4. Stephen

    nested if enhancement?

    Stephen, Mar 1, 2004, in forum: XML
    Replies:
    1
    Views:
    423
    Dimitre Novatchev [MVP XML]
    Mar 1, 2004
  5. redguardtoo
    Replies:
    0
    Views:
    316
    redguardtoo
    Jul 26, 2004
Loading...

Share This Page