http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gameprogrammer] Re: Is this valid?



I don't believe that the C++ standard specifies that std::string is
contiguous. From the SGI std::string page (I know it isn't the
standard itself, but its close:
http://www.sgi.com/tech/stl/basic_string.html) they say:

> Note that the C++ standard does not specify the complexity of basic_string operations.

If std::string was guaranteed to be contiguous std::string::operator[]
could be specified as an O(1) operation.

In practise though, most implementations appear to make std::string a
contiguous dynamic array of some sort.

On Jan 25, 2008 7:24 AM, Olivier Delannoy <olivier.delannoy@gmail.com> wrote:
> However you can write something like
>
>  std::string s;
>  s.assign(strlen("Hello world"), '\0');
>  strcpy(&s[0], "Hello world");

---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html