Alternatively, if you do not wish to support InputIterator semantics, it might be better to remove operator++(int) or have it return void instead of a conceptually invalid iterator.
--
Johannes S. Mueller-Roemer, MSc
Wiss. Mitarbeiter - Interactive Engineering Technologies (IET)
Fraunhofer-Institut für Graphische Datenverarbeitung IGD
Fraunhoferstr. 5 | 64283 Darmstadt | Germany
Tel +49 6151 155-606 | Fax +49 6151 155-139
johannes.mueller-roemer@igd.fraunhofer.de | www.igd.fraunhofer.de
From: Mueller-Roemer, Johannes Sebastian
Sent: Monday, February 16, 2015 15:00
To: boost-users@lists.boost.org
Subject: RE: [Boost-users] [context] boost::coroutines::asymmetric_coroutine<T>::pull_type iterator does not properly model InputIterator
If that is „as expected“ it still violates the requirements for an InputIterator. See the last row in Table 107 in 24.2.3 in the standard http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4296.pdf
As-is the current “iterator” is not a valid iterator of any kind as InputIterator is already the weakest requirement.
Example of how it should work (using an istream_iterator, which is an InputIterator):
#include <iostream>
#include <sstream>
#include <iterator>
auto main(int, char **) -> int
{
std::istringstream str("Hello , World !");
for(auto it = std::istream_iteratorstd::string(str); it != std::istream_iteratorstd::string();)
std::cout << *it++;
std::cout << "\n";
}
Which outputs (as expected):
Hello,World!
The issue can be solved by storing a value in the iterator or returning a proxy object which dereferences to the original value.
--
Johannes S. Mueller-Roemer, MSc
Wiss. Mitarbeiter - Interactive Engineering Technologies (IET)
Fraunhofer-Institut für Graphische Datenverarbeitung IGD
Fraunhoferstr. 5 | 64283 Darmstadt | Germany
Tel +49 6151 155-606 | Fax +49 6151 155-139
johannes.mueller-roemer@igd.fraunhofer.demailto:johannes.mueller-roemer@igd.fraunhofer.de | www.igd.fraunhofer.dehttp://www.igd.fraunhofer.de
From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Oliver Kowalke
Sent: Monday, February 16, 2015 14:20
To: boost-users@lists.boost.orgmailto:boost-users@lists.boost.org
Subject: Re: [Boost-users] [context] boost::coroutines::asymmetric_coroutine<T>::pull_type iterator does not properly model InputIterator
2015-02-16 13:46 GMT+01:00 Mueller-Roemer, Johannes Sebastian