Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2006-01-30 12:44:04


Andy Little wrote:
>"Reece Dunn" <msclrhd_at_[hidden]> wrote
> > Are you sure? You can write algorithms that don't rely on a specific
> > capacity string.
>
>OK I was under the impression you could (modify the capacity). Spell it out
>for
>me in the documentation in this case.

Noted.

> > you can write:
> >
> > int strlen( const fixed_string_base< char >& str )
> > {
> > return str.length();
> > }
>
>Its possible to do this for fixed_string directly too.
>
> template <typename T>
> typename boost::enable_if<
> is_fixed_string<T>,
> int
> >::type
> strlen( const T& str )
> {
> return str.length();
> }

But the solution is still using templates. You don't need to have a template
to use std::[w]string. Thus, if you wanted to move:

   __declspec(dllexport)
   void some_function( const std::string & str );

to use fixed_string with the implementation you mention, you would need to
expose the implementation of some_function to your customers and thus cannot
use it as part of a library (.lib) or DLL.

> > The Spirit docs are very good :).
>
>OK thats a good model . fixed_string should be easier to describe than
>Spirit
>too.

:)

> > I intend to keep the behaviour of the fixed_string class (modified,
> > according to the review feedback). This is what the unit tests are for
>:).
> > It is just *how* that is implemented that will change.
>
>What about the (lack of) overrun policy?

Coming soon to a fixed string library near you :).

The current unit tests will use the default overrun policy, which will be to
truncate the string if overrun occurs.

- Reece


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