Topic: Contiguous vector and contiguous string
Author: Dennis Yelle <dennis51@jps.net>
Date: 2000/07/24 Raw View
It seems that we will soon get the guarantee that vector is contiguous.
I think that we should also get the guarantee that string is contiguous.
There are several reasons that I think that this is a good idea:
1. Most (all?) real implementations already provide this.
Therefore, there is already user code that depends on it,
either intentionally or non intentionally.
2. It is the only sensible way to do string for short strings,
where short means less than 100 characters.
3. Most strings are very short, where very short means less than 16
characters.
4. The SGI STL, which is available for free on the web:
http://www.sgi.com/Technology/STL/
already contains a different type, rope, which is basically a
non-contiguous string: http://www.sgi.com/Technology/STL/Rope.html
5. It means that it is easy to guarantee that string::c_str() is a
constant time operation. (All you have to do is make sure that
there is always space available for the trailing '\0'.)
6. All of the reasons that contiguous vector is good, also apply
to contiguous string.
Dennis Yelle
--
I am a computer programmer and I am looking for a job.
There is a link to my resume here: http://table.jps.net/~vert
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]