Increased std::vector compatibility of fbvector
authorNicholas Ormrod <njormrod@fb.com>
Fri, 10 Aug 2012 21:04:43 +0000 (14:04 -0700)
committerTudor Bosman <tudorb@fb.com>
Sun, 26 Aug 2012 18:12:21 +0000 (11:12 -0700)
commitbf188b34715fbcd67abc29ab67296ef66567cd44
treee1cf8e333b10a3b817903118318c903380bf20cd
parentcc1518dbf05f60c5ac480209c96a48a98d01455f
Increased std::vector compatibility of fbvector

Summary:
fbvector was not accepting move_iterators for
InputIterator-templated construct, assign, and insert. The root cause
was the check '(b_ <= &*first && &*first < e_)', used to check if the
assignment was from internal data. This addressof check does not compile
with rvalue-references, and causes the first iterator to be dereferenced
more than once; both against the contract of std::vector. The standard
allows for undefined behaviour in the self-iterator case, so there are
no contractual barriers to removing this check.

Test Plan:
run fbvector test and benchmark. An fbgs for 'assign' turns
up few matches; the seem to be normal use-case. Test fbvector assign
with self-iterators in order (i.e. fbv.assign(fbv.begin(), fbv.end()));
this seems to work fine.

Reviewed By: andrei.alexandrescu@fb.com

FB internal diff: D535012
folly/FBVector.h
folly/test/FBVectorTest.cpp