From 4424232cf1053fb472ed8823c9449491bf6ea6c9 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Sun, 9 Mar 2014 15:01:44 +0100 Subject: [PATCH] bugfix for #9760 --- example/cpp11/asymmetric/Jamfile.v2 | 4 +++ example/cpp11/asymmetric/iterator_range.cpp | 30 +++++++++++++++++++ .../boost/coroutine/asymmetric_coroutine.hpp | 16 +++++----- 3 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 example/cpp11/asymmetric/iterator_range.cpp diff --git a/example/cpp11/asymmetric/Jamfile.v2 b/example/cpp11/asymmetric/Jamfile.v2 index 2900897..335f780 100644 --- a/example/cpp11/asymmetric/Jamfile.v2 +++ b/example/cpp11/asymmetric/Jamfile.v2 @@ -41,6 +41,10 @@ exe layout : layout.cpp ; +exe iterator_range + : iterator_range.cpp + ; + #exe await_emu # : await_emu.cpp # ; diff --git a/example/cpp11/asymmetric/iterator_range.cpp b/example/cpp11/asymmetric/iterator_range.cpp new file mode 100644 index 0000000..32e56d7 --- /dev/null +++ b/example/cpp11/asymmetric/iterator_range.cpp @@ -0,0 +1,30 @@ + +// Copyright Oliver Kowalke 2009. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +#include + +#include +#include +#include + +int main() +{ + using namespace boost; + coroutines::coroutine::pull_type c([](coroutines::coroutine::push_type& yield) { + for (int i = 0; i < 5; ++i) { + yield(i); + } + }); + auto crange = make_iterator_range(begin(c), end(c)); + for (auto n : crange + | adaptors::filtered([](int n){return n % 2 == 0;})) // the filtered adaptor needs const operator==. + { + std::cout << n << std::endl; + } +} diff --git a/include/boost/coroutine/asymmetric_coroutine.hpp b/include/boost/coroutine/asymmetric_coroutine.hpp index 1168f98..9b3370a 100644 --- a/include/boost/coroutine/asymmetric_coroutine.hpp +++ b/include/boost/coroutine/asymmetric_coroutine.hpp @@ -190,10 +190,10 @@ public: return * this; } - bool operator==( iterator const& other) + bool operator==( iterator const& other) const { return other.c_ == c_; } - bool operator!=( iterator const& other) + bool operator!=( iterator const& other) const { return other.c_ != c_; } iterator & operator*() @@ -353,10 +353,10 @@ public: return * this; } - bool operator==( iterator const& other) + bool operator==( iterator const& other) const { return other.c_ == c_; } - bool operator!=( iterator const& other) + bool operator!=( iterator const& other) const { return other.c_ != c_; } iterator & operator*() @@ -845,10 +845,10 @@ public: return * this; } - bool operator==( iterator const& other) + bool operator==( iterator const& other) const { return other.c_ == c_ && other.val_ == val_; } - bool operator!=( iterator const& other) + bool operator!=( iterator const& other) const { return other.c_ != c_ || other.val_ != val_; } iterator & operator++() @@ -1227,10 +1227,10 @@ public: return * this; } - bool operator==( iterator const& other) + bool operator==( iterator const& other) const { return other.c_ == c_ && other.val_ == val_; } - bool operator!=( iterator const& other) + bool operator!=( iterator const& other) const { return other.c_ != c_ || other.val_ != val_; } iterator & operator++()