Andre Poenitz <[EMAIL PROTECTED]> writes:

| On Tue, Mar 12, 2002 at 09:37:50AM +0100, Jean-Marc Lasgouttes wrote:
>> Andre> Apart from that I'd rather try to come up with some "really
>> Andre> fast" 'conststring' class which could improve most of the
>> Andre> handling of this 'strings used for convenience reasons' stuff,
>> Andre> both for memory and runtime.
>> 
>> What would such a class do to be fast?
>
| Do not much. It should just wrap 'static' const char[]'s for starters, so
| no new/delete. Of course this makes contruction of these things a bit
| harder...
>
| Something like
>
| class cstring {
| public:
|   cstring(char const * data) : data_(data) {}
| private:
|   char const * data_;
| };
>
| bool operator==(cstring const & s, cstring const & t)
| {
|   return !strcmp(s.data_, t.data_);
| }
>
| int main()
| {
|   cstring s("hello");
|   cout << (s == "hello") << "\n";
|   // i.e. syntax similar to std::string, but none of its overhead

What overhead for const string?

On speed you gain nothing.

On memory usage you gain nothing that a specialized allocator wouldn't
give you.

What would the point of such a class be?

-- 
        Lgb

Reply via email to