mirror of
https://github.com/boostorg/utility.git
synced 2025-05-09 15:04:00 +00:00
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.
Description
Boost.org utility module
Languages
C++
84.5%
HTML
15.4%
CMake
0.1%