From -6128804679395583897
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,2dadf1d1c3a45d35
X-Google-Attributes: gidf78e5,public
From: James Kanze <james-albert.kanze@vx.cit.alcatel.fr>
Subject: Re: Why basic_string != vector ?
Date: 1997/03/13
Message-ID: <rf5209kksvf.fsf@vx.cit.alcatel.fr>#1/1
X-Deja-AN: 225210051
References: <3325F838.6AEF@pratique.fr>
X-Original-Date: 13 Mar 1997 11:07:16 +0100
Organization: -
X-Auth: PGPMoose V1.1 PGP comp.std.c++
Newsgroups: comp.std.c++
Originator: fjh@murlibobo.cs.mu.OZ.AU


Valentin Bonnard <bonnardv@pratique.fr> writes:

|>  The question is in the subject line: why basic_string != vector ?
|>  
|>  basic_string provide de same basic services as vector; it just 
|>  add:
|>  - conversion from 0 terminated string 
|>  - conversion to 0 terminated string (data/c_str)
|>  - concatenation (+ and +=) with basic_string and string element
|>  - operator = with 0 terminated string and string element
|>  
|>  Basically this is:
|>  (1) conversions with 0 terminated arrays
|>  (2) one element work as an array
|>  (3) concatenation
|>  
|>  While (3) may also make sens for vector, (1) or (2) don't 
|>  often.
|>  
|>  So my question really is: why are they independent concepts ?
|>  (even if they aren't equivalent abstractions)

There are probably a number of reasons.  One of the most important is
certainly the fact that it is instantiated on a "traits" class; you can
have several basic_string's implemented over char with different
multi-byte encodings (or even different single byte encodings, e.g. ISO
8859-x), for example.  Each has a different type, and cannot (easily) be
mixed.

Note that the support for multibyte encoding is significant; the actual
value of an element (character) in a string cannot be determined
uniquely by looking at that element alone; it also depends on the
current mbstate.

-- 
James Kanze      home:     kanze@gabi-soft.fr        +33 (0)1 39 55 85 62
                 office:   kanze@vx.cit.alcatel.fr   +33 (0)1 69 63 14 54
GABI Software, Sarl., 22 rue Jacques-Lemercier, F-78000 Versailles France
	    -- Conseils en informatique industrielle --
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]



