Boost logo

Boost :

Subject: Re: [boost] [Potentially OT] String Concatenation Operator
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2010-08-26 10:19:16


On 8/26/2010 4:07 AM, Mathias Gaunard wrote:
> On 26/08/10 08:09, Dean Michael Berris wrote:
[...]
>> Maybe instead of having
>> multiple concatenations, what happens is I allocate a chunk "just
>> large enough" to hold the multiple concatenated strings, and just
>> traverse the lazy string as in your example. The copy happens at
>> runtime, the allocation of a large enough buffer (maybe a
>> boost::array) happens at compile-time (or at least the determination
>> of the size).
>
> You can't get the size of a range at compile-time.

But you can define a trait or metafunction that tells you *whether* the
range has a compile-time size (and, if so, then *what* that size is),
and go around specializing it for C arrays, Boost.Array, the Boost.Range
adaptors, etc. E.g., a transformed range is statically sized iff it's
underlying range is statically sized; a joined range is statically sized
if *all* its underlying ranges are statically sized; etc.

Something like that may be what the OP is looking for...

- Jeff


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