From: Phil Nash (phil.nash.lists_at_[hidden])
Date: 2003-03-06 06:00:36
> Robert Klarer wrote:
> > The syntax for declaring a static_string is unfortunate, but once it has
> > been declared, a static_string's interface is (almost*) the same as that
> > of a const std::string.
> Yes, you right it's unfortunate and IMHO is not appropriate for a wide
> > typedef boost::static_string<'s', 't', 'a', 't', 'i', 'c', '_'>
> > StrType1;
> This syntax may be good for some specific (and not widely used) tasks such
> as building hashing algorithm at compile-time for a given set of static
> strings but not for "normal" strings.
> I beveive it's better to wait for a new compiler which can optimize
> memory allocations (a possibly even more) away.
Hmm, but on the other hand, perhaps this is an area that a simple code
generator might be practical. If you keep all your string literals
(especially localisable strings) in separate files already these string
files could be generated to use static_string - and so the syntax would not
have to be manipulated. In fact if the code generator took a C++ file of
string literal declarations as source and worked both ways swapping them in
and out maybe quite trivial.
I know code generators are not universally popular and I always template
meta-programming where possible, even if a little more complex, but this
could be a useful case for those that choose it....?
I have to admit I like the idea of having a std::string interface without
the overhead of dynamic allocation.
My biggest reservation would by the char-only restriction...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk