Boost logo

Boost Users :

Subject: [Boost-users] range: partition a transformed range adaptor
From: Auer, Jens (jens.auer_at_[hidden])
Date: 2015-10-02 06:18:02


Hi,

So today I wanted to partition a transformed range. I came up with something like
   std::vector<int> v;

    auto t2 = r | transformed( [](int) {return 0;} );
    auto p2 = boost::range::partition(t2, [](int) {return true;} ); , but that didn't work. On Stackoverflow, it was explained that this doesn't work because partition needs to modify the range, and a transformed range is not modifiable. So far so good, I can follow this and see why and modify the program to use transform on the vector directly.

What bothers me is that I was not able to figure that out from the documentation, and that the error message was not very intuitive to say the least. According to the documentation, the requirements on the range for partition are that it has to be a model of ForwardRange, which means that the iterators have to be forward traversable iterators. I think the important fact, namely that it has to be writeable iterator, is missing from the documentation completely. As far as I can see, readable/writable categories are not used in the range documentation at all.

Best wishes,
  Jens

--
Dr. Jens Auer | CGI | Software Engineer
CGI Deutschland Ltd. & Co. KG
Rheinstraße 95 | 64295 Darmstadt | Germany
T: +49 6151 36860 154
jens.auer_at_[hidden]
Unsere Pflichtangaben gemäß § 35a GmbHG / §§ 161, 125a HGB finden Sie unter de.cgi.com/pflichtangaben.
CONFIDENTIALITY NOTICE: Proprietary/Confidential information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply e-mail.

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