Opened 5 years ago
Closed 5 years ago
#13002 closed Bugs (duplicate)
boost::prior does not compile when used with std::set reverse_iterator
| Reported by: | Owned by: | No-Maintainer | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | utility |
| Version: | Boost 1.61.0 | Severity: | Regression |
| Keywords: | Cc: |
Description
Given the following code snippet:
#include <boost/prior_next.hpp>
#include <set>
int main(int argc, char *argv[])
{
std::set<int> myints { 1, 2, 3, 4, 5 };
boost::prior(myints.rbegin(), 1);
return 0;
}
This fails to compile against boost 1.61.0.
$ g++ -std=c++11 boost-test.cpp
In file included from /usr/lib/gcc/x86_64-redhat-linux-gnu/4.8.3/include/c++/iterator:63:0,
from /usr/include/boost/next_prior.hpp:15,
from boost-test.cpp:1:
/usr/lib/gcc/x86_64-redhat-linux-gnu/4.8.3/include/c++/bits/stl_iterator.h: In instantiation of ‘std::reverse_iterator<_Iterator>& std::reverse_iterator<_Iterator>::operator-=(std::reverse_iterator<_Iterator>::difference_type) [with _Iterator = std::_Rb_tree_const_iterator<int>; std::reverse_iterator<_Iterator>::difference_type = long int]’:
/usr/include/boost/next_prior.hpp:138:11: required from ‘static T boost::next_prior_detail::prior_impl1<T, Distance, true>::call(T, Distance) [with T = std::reverse_iterator<std::_Rb_tree_const_iterator<int> >; Distance = int]’
/usr/include/boost/next_prior.hpp:160:68: required from ‘T boost::prior(T, Distance) [with T = std::reverse_iterator<std::_Rb_tree_const_iterator<int> >; Distance = int]’
boost-test.cpp:7:36: required from here
/usr/lib/gcc/x86_64-redhat-linux-gnu/4.8.3/include/c++/bits/stl_iterator.h:265:10: error: no match for ‘operator+=’ (operand types are ‘std::_Rb_tree_const_iterator<int>’ and ‘std::reverse_iterator<std::_Rb_tree_const_iterator<int> >::difference_type {aka long int}’)
current += __n;
^
There do not appear to be any further changes to boost/next_prior.hpp since the current state of that file in 1.61 after commit 651a869, so it is identical to the header shipped in 1.64.
Note:
See TracTickets
for help on using tickets.

Duplicates #10847.