Project

General

Profile

Bug #17431

Missing stuff in RangeForWrapperIterator

Added by Giuseppe Cerati about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Urgent
Category:
Library
Target version:
-
Start date:
08/10/2017
Due date:
% Done:

100%

Estimated time:
2.00 h
Spent time:
Occurs In:
Experiment:
-
Co-Assignees:
Duration:

Description

Missing iterator traits for RangeForWrapperIterator; also missing const functions begin and end in RangeForWrapperBox

A few ideas (you are welcome!):
using pointer = std::add_pointer_t<std::remove_reference_t<value_type>>;
using reference = std::add_lvalue_reference_t<std::remove_reference_t<value_type>>;
using difference_type = std::ptrdiff_t;
using iterator_category = typename std::iterator_traits<begin_t>::iterator_category;

Associated revisions

Revision e26696ac (diff)
Added by Gianluca Petrillo about 3 years ago

Added support for up to bidirectional iterators in util::RangeForWrapper.

This solves part of issue #17431.

Revision 591830fe (diff)
Added by Gianluca Petrillo about 3 years ago

begin() and end() methods of RangeForWrapper are made constant.

This will allow a solution for the remaining part of issue #17431.

Revision 338571e4 (diff)
Added by Gianluca Petrillo about 3 years ago

Added support for up to bidirectional iterators in util::RangeForWrapper.

This solves part of issue #17431.

Revision 0c81ac41 (diff)
Added by Gianluca Petrillo about 3 years ago

begin() and end() methods of RangeForWrapper are made constant.

This will allow a solution for the remaining part of issue #17431.

History

#1 Updated by Giuseppe Cerati about 3 years ago

Giuseppe Cerati wrote:

using iterator_category = typename std::iterator_traits<begin_t>::iterator_category;

or maybe one of these? http://en.cppreference.com/w/cpp/iterator/iterator_tags

#2 Updated by Gianluca Petrillo about 3 years ago

  • Category set to Library
  • Status changed from New to Assigned
  • Estimated time set to 2.00 h

#3 Updated by Gianluca Petrillo about 3 years ago

  • % Done changed from 0 to 80

While working on this, I have added full support for iterators up to bidirectional.

#4 Updated by Gianluca Petrillo about 3 years ago

  • Status changed from Assigned to Resolved
  • % Done changed from 80 to 100

The purpose of util::RangeForWrapper is to bridge the code that uses ranve v3 library to C++17.
At that point, the language will support range objects in range-for loops directly.
Beyond that, the range objects can already be used directly. The way to get their iterators is via free functions:

auto r = gimmeArange();

using std::begin;
auto b = begin(r);
using std::end;
auto e = end(r);

using std::cbegin;
auto cb = cbegin(r);
using std::cend;
auto ce = cend(r);

retrieve the iterators (the latter, always constant; the former, also constant if such is the range).
This will be the only supported way when C++17 is available and util::RangeForWrapper will be gone, and it is the only supported way today.

I have fixed util::RangeForWrapper so that the constructs above work.

Since it's a bug fix, the new code is in develop branch of lardata.

#5 Updated by Gianluca Petrillo about 3 years ago

  • Status changed from Resolved to Closed


Also available in: Atom PDF