|
|
Chambers <ben### [at] pacificwebguycom> wrote:
> Why they couldn't just add a native string class to the
> language itself eludes me at the moment."
My guess: Because they wanted it to be possible for the user to specify
his own allocator for a string.
One guiding principle I see throughout the C++ standard library is that
it's rather flexible: For example, containers don't fix the memory allocator
they use to allocate space, but let the user specify his own allocator if
he wants to use one (eg. because of efficiency in certain situations, or
to allow some kind of user-implemented automatic garbage collection).
Normally a default allocator is used, and the user doesn't need to worry
about it. However, if the user wants to replace the allocator, he can.
If you think how you would add a native, language-level string (ie. not
just a class in a library) which would support a user-defined allocator
in C++, you would quite quickly find yourself reimplementing a templated
string class at language level.
--
- Warp
Post a reply to this message
|
|