Boost logo

Boost :

From: John Nagle (nagle_at_[hidden])
Date: 2004-06-16 22:19:21


    That's a much better approach than the previous one.
It's sound C++, and it's simple.
All the operations go in string_base. fixed_string
need only allocate space. Where do you hit a problem?

                        John Nagle

Reece Dunn wrote:
> John Nagle wrote:
>
>> I think we're back to using an abstract base class.
>> The hacks to get around it introduce worse problems.
>
>
> I would agree. I have been trying to find a way around the problem and
> have (sortof) by having a base class:
>
> template< typename CharT >
> class string_base
> {
> private:
> size_t len, cap; // length & capacity
> CharT * buf; // data buffer
> public:
> string_base( CharT * b, size_t c, size_t l ):
> len( l ), cap( c ), buf( b ){}
> // non-virtual implementation
> };
>
> template< size_t n, typename CharT >
> class fixed_string: public string_base
> {
> private:
> CharT data[ n + 1 ];
> public:
> fixed_string(): string_base( data, n + 1 ){}
> };


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk