Boost logo

Boost :

From: John Nagle (nagle_at_[hidden])
Date: 2004-06-04 13:58:47

Rob Stewart wrote:

> From: "Reece Dunn" <msclrhd_at_[hidden]>

>>I am looking for a better solution to this. I am also thinking about how to
>>remove the ABC from the implementation using a technique pointed out by
>>someone on this thread (can't remember who):
>> class fs_base
>> {
>> size_t len;
>> szie_t capacity; // needed for buffer-safe operations
>> CharT str[ 1 ];
>> // string manipulation functions
>> fs_base( size_t c ): capacity( c ){}
>> };
>> template< size_t n >
>> class fixed_string: public fs_base
>> {
>> CharT data[ n ];
>> fixed_string(): fs_base( n ){}
>> };
>>I'll need to look into this, to see what effect this will have, to see if it
>>is a possible replacement for the ABC. What do other people think?

     Are you assuming that "data[n]" physically follows
"str[1]" in memory, and that "data[n]" can be addressed
by subscripting "str[1]" out of range? That will
work with most implementations, but it's not guaranteed
to work. There are often intervening alignment bytes.
Some debug implementations may place sentinel
areas between objects to detect buffer overruns.

                                        John Nagle

Boost list run by bdawes at, gregod at, cpdaniel at, john at