[gameprogrammer] Re: Is this valid?
- From: Brian <brian.ripoff@xxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Fri, 25 Jan 2008 11:57:06 +0000
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@xxxxxxxxx> 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
- Follow-Ups:
- [gameprogrammer] Re: Is this valid?
- From: Paulo Pinto
- References:
- [gameprogrammer] Is this valid?
- From: Kevin Jenkins
- [gameprogrammer] Re: Is this valid?
- From: Matthew Weigel
- [gameprogrammer] Re: Is this valid?
- From: Olivier Delannoy
Other related posts:
- [gameprogrammer] Re: Is this valid?
- From: Paulo Pinto
- [gameprogrammer] Is this valid?
- From: Kevin Jenkins
- [gameprogrammer] Re: Is this valid?
- From: Matthew Weigel
- [gameprogrammer] Re: Is this valid?
- From: Olivier Delannoy