6 Commits

Author SHA1 Message Date
Andrey Semashev
6cf9c22cf1 Reworked iterator handling in next/prior helpers.
The new implementation tries to detect if the incremented/decremented type
is an iterator first and if not falls back to operator probing. This way
iterators that are not SFINAE-friendly (i.e. unconditionally define
arithmetic operators regardless of the iterator category) are still treated
as iterators through std::advance and do not fail the compilation.

The iterator detection is based on probing for the nested iterator_category
type that is expected to be present in class-type iterators. This heuristic
is not flawless since iterators are not required to defined this type.
User-defined iterators may not have it and instead specialize
std::iterator_traits. This use case is not covered by the current implementation
and will likely fail to compile. With C++17 SFINAE-friendly std::iterator_traits
this can be fixed, but currently Boost.Config lacks the macro to detect
availability of this feature. Support for it can be added by a later commit.

Also simplified boost::prior for iterators, removing the possibility of
integer overflow caused by negation of the distance value.
2017-07-09 03:10:01 +03:00
Andrey Semashev
651a869d4f Reworked next() and prior() taking the distance arguments.
The new version should provide the expected behavior in the case (prior(v.end(), v.size()) == v.begin()). It should also work with integers now, as was originally intended by David Abrahams. Added tests to verify these new use cases.
2014-06-24 01:05:32 +04:00
John Maddock
acd2e6ef2b Added Daryle Walker's copyrights as requested.
[SVN r24481]
2004-08-15 10:13:49 +00:00
John Maddock
d8b0ff2d7e Removed Boost.org copyrights and replaced with originating authors copyright instead.
[SVN r24372]
2004-08-10 12:53:34 +00:00
Dave Abrahams
dfc320124f Extended next/prior using patch from Daniel Walker (Daniel.Walker-at-bowneglobal.com)
[SVN r21382]
2003-12-23 14:59:59 +00:00
Aleksey Gurtovoy
80df1d8f12 split utility.hpp header
[SVN r17472]
2003-02-17 06:20:57 +00:00