Boost logo

Boost :

Subject: Re: [boost] [range] for_each and std::map of std::list
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-04-07 14:24:08


On Thu, Apr 7, 2011 at 11:17 AM, Jeremy Maitin-Shepard
<jeremy_at_[hidden]>wrote:

> On 04/07/2011 04:39 AM, Mathias Gaunard wrote:
>
>> On 07/04/2011 12:56, Thorsten Ottosen wrote:
>>
>> Well, that is only a problem if you want to avoid manually applying the
>>> adaptor twice (or more), right?
>>>
>>> If so, I think that is a limitation we can live with. A simple solution
>>> covers most cases IMO.
>>>
>>
>> Oh, the adaptor I wrote flattens recursively.
>>
>> I guess just flattening the top level could be fairly easy.
>>
>
> You could also require that the user specify the number of levels of
> recursion explicitly, as in many cases the final value_type you want to
> iterate over may be a range itself. Consider, for instance, that a string
> is itself a range of characters, but in many cases the user would not want
> to flatten a range of strings into a range of characters.
>

+1

I don't think auto-detecting the flattening depth is the way to go. The
closest that makes sense to me is to create a mechanism to "flatten until
value_type == whatever", but that can be built as a layer on top of
explicitly specifying the flattening depth.

I've done this before, it's kind of a PITA and I currently don't like my
current implementation and had plans at some point to rework it...

- Jeff


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