Boost logo

Boost Users :

Subject: Re: [Boost-users] Reverse for loop with boost::adaptors::reverse crashes
From: Filip Konvička (filip.konvicka_at_[hidden])
Date: 2014-11-25 12:09:58


> Maybe this is basic C++ I should understand; it looks like the
> temporary vector returned by getv() gets destroyed in the 2nd loop
> too soon. I was wondering whether the adaptor could warn me that
> I'm using it in a wrong way (the code looks so nice and compiles
> cleanly...).
>
>
> Hi, I maintain the Boost.Range library and this issue is the most
> frustrating one. I've been unable to come up with a solution that does
> not unacceptably deteriorate performance in valid cases. I've thrown the
> problem wide open to the list and a number of other people and there
> haven't been any solutions that wouldn't ruin the interface or
> performance. I can only apologise for failing to address this. I've
> tried for many hours to find a solution, but failed.
>
> Our hope is with Range V3 and the standardisation proposal from Eric
> Niebler. He has defined the lifetime of new Iterables and Range Concepts
> to avoid this problem. With a new interface we can fix the problem.
>
> I'm still open to solutions for the V2 Boost.Range. I'd certainly not
> like to be irrationally blocking progress. The current recommendation is
> to take a temporary outside of the loop. This can often be a const
> reference temporary to extend the lifetime sufficiently.
>
> Regards,
> Neil Groves

Neil,

Thanks for your explanation. There is absolutely no need to apologize.
  I believe this is rather a language design flaw than anything else.

I think that it would be great if there was a section on this subject in
the documentation (just from the user's perspective, no detailed
analysis). I admit that I haven't read all of the Boost.Range
documentation so I hope that I haven't missed it by accident.

Thank you,
Filip


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net