> 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 use. > > > 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 dynamic > 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... Regards, [)o IhIL.. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
