Subject: Re: [Boost-bugs] [Boost C++ Libraries] #12071: Using iterator_facade with range-v3 fails to compile (was: postfix_increment_proxy is not DefaultConstructible and doesn't have a nested public value_type)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-04-20 15:21:25
#12071: Using iterator_facade with range-v3 fails to compile
----------------------------------------------+----------------------------
Reporter: Krzysztof CzaiÅski <1czajnik@â¦> | Owner:
Type: Bugs | jeffrey.hellrung
Milestone: To Be Determined | Status: new
Version: Boost 1.61.0 | Component: iterator
Resolution: | Severity: Problem
| Keywords: range-v3
----------------------------------------------+----------------------------
Comment (by Krzysztof CzaiÅski <1czajnik@â¦>):
Maybe a high-level example will be helpful:
{{{
#include <iostream>
#include "third_party/boost/allowed/iterator/iterator_facade.hpp"
#include "third_party/range_v3/include/range/v3/algorithm/copy.hpp"
#include "third_party/range_v3/include/range/v3/iterator_range.hpp"
#include "third_party/range_v3/include/range/v3/utility/iterator.hpp"
template <class V, class Category>
class TestIter
: public boost::iterator_facade<TestIter<V, Category>, V, Category, V>
{
public:
using typename boost::iterator_facade<TestIter<V, Category>, V,
Category,
V>::difference_type;
TestIter() : v_() {}
explicit TestIter(V v) : v_(v) {}
private:
friend class boost::iterator_core_access;
V dereference() const { return v_; }
bool equal(const TestIter& other) const { return v_ == other.v_; }
void increment() { ++v_; }
void decrement() { --v_; }
void advance(difference_type n) { v_ += n; }
difference_type distance_to(const TestIter& other) const {
return other.v_ - v_;
}
V v_;
};
using InIter = TestIter<int, std::input_iterator_tag>;
template <class R>
void print(R&& r) {
ranges::copy(std::forward<R>(r), ranges::ostream_iterator<>(std::cout,
", "));
std::cout << "\n";
}
int main() {
print(ranges::make_iterator_range(InIter(1), InIter(10)));
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/12071#comment:2> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC