|
Boost : |
From: Markus Werle (numerical.simulation_at_[hidden])
Date: 2003-11-07 09:28:40
Pavol Droba wrote:
> On Fri, Nov 07, 2003 at 02:03:15PM -0800, John Torjo wrote:
>>
>> Matthew Hurd wrote:
>>
>> >Any lib related to Boost that uses expression templates for string or
>> >buffer
>> >operations to minimize the temporary objects? Only thinking of
>> >concatenation but I guess it might apply elsewhere.
>> >
>> >Might be a neat addition to the string algorithm library.
>>
>> I would think so ;)
>> However, I'm not sure how realistic this could be.
>> Just consider this:
>>
>> for ( int i = 0; i < 10000; ++i)
>> s += "s";
>>
>> In cases like this, expression templates would be useless, IMO.
>>
>> Anyway, Pavol, any thoughts?
>>
>
> Expression templates might be an interesting idea, but I don't think that
> it fits into the scope of the string_algo library.
> This is more related as an extension to std::string. string_algo library
> does not work with str::string only and it is oriented towards algorithms.
>
> Besides that, it could be hard to estimate the benefits, that such a
> framework could bring.
> There isn't realy much to optimize except to removing temporary objects.
> Given that fact, that string expression are usualy not very complicated
> and usualy contains only a small number of operations, it is easy to
> rewrite such an expression to use in-place variants if an optimalization
> is required.
>
> Anyway, if somebody could come with such a framework, I'll be interested
> to see it.
The "framework" is there: Daixtrose.
Plugging a
template <const char Name[256]> class SpecialString
into it is partly demonstrated at
http://daixtrose.sourceforge.net/themanual.html#x1-190003.4.7
The string concatenation is missing in that example,
but I tried this already, just dropped it because I did not
need it. Hint: the length information can be transported via the
disambiguation mechanism.
Also: John is right. Any good std::string class has memory strategies
that fit well for every day's life.
Markus
-- Build your own Expression Template Library with Daixtrose! Visit http://daixtrose.sourceforge.net/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk