Thanks! > On 2015-Jan-22, at 10:33, Marshall Clow <[email protected]> wrote: > > Author: marshall > Date: Thu Jan 22 12:33:29 2015 > New Revision: 226847 > > URL: http://llvm.org/viewvc/llvm-project?rev=226847&view=rev > Log: > Fix PR#22284. Add a new overload to deque::insert to handle forward > iterators. Update tests to exercise this case. > > Modified: > libcxx/trunk/include/deque > > libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp > > Modified: libcxx/trunk/include/deque > URL: > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/deque?rev=226847&r1=226846&r2=226847&view=diff > ============================================================================== > --- libcxx/trunk/include/deque (original) > +++ libcxx/trunk/include/deque Thu Jan 22 12:33:29 2015 > @@ -117,7 +117,7 @@ public: > iterator insert(const_iterator p, value_type&& v); > iterator insert(const_iterator p, size_type n, const value_type& v); > template <class InputIterator> > - iterator insert (const_iterator p, InputIterator f, InputIterator l); > + iterator insert(const_iterator p, InputIterator f, InputIterator l); > iterator insert(const_iterator p, initializer_list<value_type> il); > void pop_front(); > void pop_back(); > @@ -1332,11 +1332,15 @@ public: > iterator insert(const_iterator __p, const value_type& __v); > iterator insert(const_iterator __p, size_type __n, const value_type& __v); > template <class _InputIter> > - iterator insert (const_iterator __p, _InputIter __f, _InputIter __l, > + iterator insert(const_iterator __p, _InputIter __f, _InputIter __l, > typename > enable_if<__is_input_iterator<_InputIter>::value > - > &&!__is_bidirectional_iterator<_InputIter>::value>::type* = 0); > + > &&!__is_forward_iterator<_InputIter>::value>::type* = 0); > + template <class _ForwardIterator> > + iterator insert(const_iterator __p, _ForwardIterator __f, > _ForwardIterator __l, > + typename > enable_if<__is_forward_iterator<_ForwardIterator>::value > + > &&!__is_bidirectional_iterator<_ForwardIterator>::value>::type* = 0); > template <class _BiIter> > - iterator insert (const_iterator __p, _BiIter __f, _BiIter __l, > + iterator insert(const_iterator __p, _BiIter __f, _BiIter __l, > typename > enable_if<__is_bidirectional_iterator<_BiIter>::value>::type* = 0); > #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS > _LIBCPP_INLINE_VISIBILITY > @@ -2098,7 +2102,7 @@ template <class _InputIter> > typename deque<_Tp, _Allocator>::iterator > deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter > __l, > typename > enable_if<__is_input_iterator<_InputIter>::value > - > &&!__is_bidirectional_iterator<_InputIter>::value>::type*) > + > &&!__is_forward_iterator<_InputIter>::value>::type*) > { > __split_buffer<value_type, allocator_type&> __buf(__base::__alloc()); > __buf.__construct_at_end(__f, __l); > @@ -2107,6 +2111,20 @@ deque<_Tp, _Allocator>::insert(const_ite > } > > template <class _Tp, class _Allocator> > +template <class _ForwardIterator> > +typename deque<_Tp, _Allocator>::iterator > +deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, > _ForwardIterator __l, > + typename > enable_if<__is_forward_iterator<_ForwardIterator>::value > + > &&!__is_bidirectional_iterator<_ForwardIterator>::value>::type*) > +{ > + size_type __n = _VSTD::distance(__f, __l); > + __split_buffer<value_type, allocator_type&> __buf(__n, 0, > __base::__alloc()); > + __buf.__construct_at_end(__f, __l); > + typedef typename __split_buffer<value_type, allocator_type&>::iterator > __fwd; > + return insert(__p, move_iterator<__fwd>(__buf.begin()), > move_iterator<__fwd>(__buf.end())); > +} > + > +template <class _Tp, class _Allocator> > template <class _BiIter> > typename deque<_Tp, _Allocator>::iterator > deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l, > > Modified: > libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp > URL: > http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp?rev=226847&r1=226846&r2=226847&view=diff > ============================================================================== > --- > libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp > (original) > +++ > libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp > Thu Jan 22 12:33:29 2015 > @@ -46,11 +46,49 @@ make(int size, int start = 0 ) > > template <class C> > void > -test(int P, C& c1, const C& c2) > +test(int P, const C& c0, const C& c2) > { > + { > + typedef typename C::iterator I; > + typedef typename C::const_iterator CI; > + typedef input_iterator<CI> BCI; > + C c1 = c0; > + std::size_t c1_osize = c1.size(); > + CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end())); > + assert(i == c1.begin() + P); > + assert(c1.size() == c1_osize + c2.size()); > + assert(distance(c1.begin(), c1.end()) == c1.size()); > + i = c1.begin(); > + for (int j = 0; j < P; ++j, ++i) > + assert(*i == j); > + for (int j = 0; j < c2.size(); ++j, ++i) > + assert(*i == j); > + for (int j = P; j < c1_osize; ++j, ++i) > + assert(*i == j); > + } > + { > + typedef typename C::iterator I; > + typedef typename C::const_iterator CI; > + typedef forward_iterator<CI> BCI; > + C c1 = c0; > + std::size_t c1_osize = c1.size(); > + CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end())); > + assert(i == c1.begin() + P); > + assert(c1.size() == c1_osize + c2.size()); > + assert(distance(c1.begin(), c1.end()) == c1.size()); > + i = c1.begin(); > + for (int j = 0; j < P; ++j, ++i) > + assert(*i == j); > + for (int j = 0; j < c2.size(); ++j, ++i) > + assert(*i == j); > + for (int j = P; j < c1_osize; ++j, ++i) > + assert(*i == j); > + } > + { > typedef typename C::iterator I; > typedef typename C::const_iterator CI; > typedef bidirectional_iterator<CI> BCI; > + C c1 = c0; > std::size_t c1_osize = c1.size(); > CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end())); > assert(i == c1.begin() + P); > @@ -63,6 +101,7 @@ test(int P, C& c1, const C& c2) > assert(*i == j); > for (int j = P; j < c1_osize; ++j, ++i) > assert(*i == j); > + } > } > > template <class C> > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
