Example of how valid semantics could be achieved (as replacement for the old operator++(int), modulo potential mistakes):
struct proxy_reference
{
proxy_reference(typename iterator::value_type const & v) : v(v) {}
typename iterator::value_type const & operator*() const { return v; }
private:
typename iterator::value_type v;
};
proxy_reference operator++( int)
{
proxy_reference tmp(**this);
++*this;
return tmp;
}
--
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:41
To: 'boost-users@lists.boost.org'
Subject: RE: [Boost-users] [context] boost::coroutines::asymmetric_coroutine<T>::pull_type iterator does not properly model InputIterator
The temporary variable would not have to store the execution state of the coroutine, only the yielded value. Offering a broken postfix increment is very dangerous and should be avoided. Also, if I can’t count on InputIterator features being supported, the following is a lie:
class iterator : public std::iterator< std::input_iterator_tag, typename remove_reference< R >::type >
(taken from asymmetric_coroutine.hpp)
--
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 15:28
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
coroutines behave different than ordinary containers - even a temp var, created inside iterator::operator++( int), will influence the state of the attached coroutine (increment operator)
you can't count on the feature set described for input iterators in the standard
2015-02-16 15:00 GMT+01:00 Mueller-Roemer, Johannes Sebastian