<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Jan 21, 2014, at 11:20 PM, Dan Dylan <<a href="mailto:dany.dylan@gmail.com">dany.dylan@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div><div><div><div><div>The code for vector insert method<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span style="font-family:courier new,monospace">template <class _Tp, class _Allocator></span><br>
<span style="font-family:courier new,monospace">template <class _ForwardIterator></span><br><span style="font-family:courier new,monospace">typename enable_if</span><br><span style="font-family:courier new,monospace"><</span><br>
<span style="font-family:courier new,monospace">    __is_forward_iterator<_ForwardIterator>::value &&</span><br><span style="font-family:courier new,monospace">    is_constructible<</span><br><span style="font-family:courier new,monospace">       _Tp,</span><br>
<span style="font-family:courier new,monospace">       typename iterator_traits<_ForwardIterator>::reference>::value,</span><br><span style="font-family:courier new,monospace">    typename vector<_Tp, _Allocator>::iterator</span><br>
<span style="font-family:courier new,monospace">>::type</span><br><span style="font-family:courier new,monospace">vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last)</span><br>
<span style="font-family:courier new,monospace"></span></blockquote><br></div>(starting at line 1870 in file include/vector) requires that _ForwardIterator be copy assignable at line 1900.<br><br>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.<br>
<br></div>Does _ForwardIterator have to be copy assignable?<br></div></div></div></div></blockquote><div><br></div>I believe so.</div><div><br></div><div>24.2.2/2 (Iterator) says:</div><div><br></div><div><div>• A type X satisfies the Iterator requirements if:<br>— X satisfies the CopyConstructible, CopyAssignable, and Destructible requirements (17.6.3.1) and lvalues of type X are swappable (17.6.3.2), and<br>— the expressions in Table 106 are valid and have the indicated semantics.</div><div>… and so on.</div><div><br></div><div>- -  and - - </div><div>24.2.3/1 (Input Iterator) says:</div><div><br></div><div><div>• A class or pointer type X satisfies the requirements of an input iterator for the value type T if X satisfies the Iterator (24.2.2) and EqualityComparable (Table 17) requirements and the expressions in Table 107 are valid and have the indicated semantics.</div></div><div>… and so on.</div><div><br></div><div><div>- -  and (finally!) - - </div></div><div>24.2.5/1 (Forward Iterator) says:</div><div><br></div><div>• A class or pointer type X satisfies the requirements of a forward iterator if<br><span class="Apple-tab-span" style="white-space: pre;">     </span>• —  X satisfies the requirements of an input iterator (24.2.3),<br><div><span class="Apple-tab-span" style="white-space: pre;">   </span>• —  X satisfies the DefaultConstructible requirements (17.6.3.1),</div></div><div>… and so on.</div><div><br></div><div>So, to be a forward iterator is to be an input iterator is to be an iterator .. which means it has to be CopyConstructible and CopyAssignable.</div><div><br></div><div>— Marshall</div><div><br></div></div></body></html>