Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
1 changed file
with
71 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters