[cfe-dev] vector insert in libc++ release_34

Dan Dylan dany.dylan at gmail.com
Tue Jan 21 23:20:02 PST 2014


The code for vector insert method

template <class _Tp, class _Allocator>
> template <class _ForwardIterator>
> typename enable_if
> <
>     __is_forward_iterator<_ForwardIterator>::value &&
>     is_constructible<
>        _Tp,
>        typename iterator_traits<_ForwardIterator>::reference>::value,
>     typename vector<_Tp, _Allocator>::iterator
> >::type
> vector<_Tp, _Allocator>::insert(const_iterator __position,
> _ForwardIterator __first, _ForwardIterator __last)
>

(starting at line 1870 in file include/vector) requires that
_ForwardIterator be copy assignable at line 1900.

Normally forward iterators will be copy assignable, but there are cases
when the iterator is not.  One such case is when using
boost::filter_iterator with a Predicate type that is not copy assignable.

Does _ForwardIterator have to be copy assignable? or
Is the use of the enable_if template incomplete for this case? or
Is this a fault in boost::filter_iterator with its traits specification?
Or is the code wrong?  (there's a simple fix to it, but it may be too
simple!) or
Something else?

Attached is a short program that exhibits the problem.  It compiles and
runs with gcc 4.8.1 and clang 3.4 when using gcc's includes.  It fails to
compile when using libc++ includes.

Cheers
Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140122/eb1f26cf/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vector.cpp
Type: text/x-c++src
Size: 1282 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140122/eb1f26cf/attachment.cpp>


More information about the cfe-dev mailing list