Boost logo

Boost :

Subject: Re: [boost] [range]slicing any_range
From: Takatoshi Kondo (redboltz_at_[hidden])
Date: 2013-12-24 21:25:41

On Tue, Dec 24, 2013 at 8:48 PM, Takatoshi Kondo <redboltz_at_[hidden]> wrote:
>> typedef boost::any_range<int, boost::random_access_traversal_tag, int,
>> std::ptrdiff_t> int_range;

I realized the problem in my code. int_range doesn't support a
reference. It should be
typedef boost::any_range<int, boost::random_access_traversal_tag, int&,
 std::ptrdiff_t> int_range;

If the boost::iterator_facade is passed the template arguments
boost::random_access_traversal_tag as Traversal and no reference type
as Reference, the iterator_category is input_iterator due to a lack of
reference support.

I checked facade_iterator_category.hpp and wrote the following test
code to clarify my understanding.

#include <boost/iterator/iterator_facade.hpp>

struct my_iter:boost::iterator_facade<my_iter, int,
boost::random_access_traversal_tag, int&> {};
struct my_iter_noref:boost::iterator_facade<my_iter, int,
boost::random_access_traversal_tag, int> {};
int main() {
  // has reference
>::value, "");
  // no reference
>::value, "");
>::value, "");

Takatoshi Kondo

Boost list run by bdawes at, gregod at, cpdaniel at, john at