Opened 7 years ago

Closed 7 years ago

#11558 closed Bugs (invalid)

boost transform iterator doesn't work with libc++

Reported by: rnickb731@… 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)

main.cpp (741 bytes ) - added by anonymous 7 years ago.

Download all attachments as: .zip

Change History (3)

by anonymous, 7 years ago

Attachment: main.cpp added

comment:1 by Michel Morin, 7 years ago

Component: Noneiterator
Owner: set to jeffrey.hellrung

comment:2 by Michel Morin, 7 years ago

Resolution: invalid
Status: newclosed

Your iterator is InputIterator (note: reference type of the iterator is int) but std::next requires ForwardIterator. Thus, the compilation fails if stdlib explicitly checks iterator requirements.

So this is not a bug of Boost.Iterator and one can use boost::next in <boost/next_prior.hpp> to avoid this problem.

Note: See TracTickets for help on using tickets.