Opened 7 years ago
Closed 7 years ago
#11558 closed Bugs (invalid)
boost transform iterator doesn't work with libc++
| Reported by: | Owned by: | jeffrey.hellrung | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | iterator |
| Version: | Boost 1.57.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
The following code won't compile with clang using these options:
clang++ -std=c++14 -stdlib=libc++ main.cpp
#include <boost/iterator/counting_iterator.hpp> #include <boost/iterator/transform_iterator.hpp> double f(int i) { return i; } int main() {
auto i = boost::make_transform_iterator(boost::make_counting_iterator(3), f); std::next(i); return 0;
}
It gives me this error:
main.cpp:8:3: error: no matching function for call to 'next'
std::next(i);
/usr/local/bin/../include/c++/v1/iterator:510:25: note: candidate template ignored: disabled by 'enable_if' [with
_ForwardIter = boost::iterators::transform_iterator<double (*)(int), boost::iterators::counting_iterator<int, boost::iterators::use_default, boost::iterators::use_default>, boost::iterators::use_default, boost::iterators::use_default>]
typename enable_if<is_forward_iterator<_ForwardIter>::value>::type* = 0)
1 error generated.
Attachments (1)
Change History (3)
by , 7 years ago
comment:1 by , 7 years ago
| Component: | None → iterator |
|---|---|
| Owner: | set to |
comment:2 by , 7 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |

Your iterator is
InputIterator(note:referencetype of the iterator isint) butstd::nextrequiresForwardIterator. Thus, the compilation fails if stdlib explicitly checks iterator requirements.So this is not a bug of Boost.Iterator and one can use
boost::nextin<boost/next_prior.hpp>to avoid this problem.