void assignImpl(InputIterator first, InputIterator last, boost::false_type) {
// Pair of iterators
if (fbvector_detail::isForwardIterator<InputIterator>::value) {
- if (b_ <= &*first && &*first < e_) {
- // Aliased assign, work on the side
- fbvector result(first, last);
- result.swap(*this);
- return;
- }
-
auto const oldSize = size();
auto const newSize = std::distance(first, last);
// Can compute distance
auto const n = std::distance(first, last);
if (e_ + n >= z_) {
- if (b_ <= &*first && &*first < e_) {
- // Ew, aliased insert
- goto conservative;
- }
auto const m = position - b_;
reserve(size() + n);
position = b_ + m;
} else {
// Cannot compute distance, crappy approach
// TODO: OPTIMIZE
- conservative:
fbvector result(cbegin(), position);
auto const offset = result.size();
FOR_EACH_RANGE (i, first, last) {
EXPECT_EQ("Cycle detected: [baz] [bar] [foo] ", message);
}
+TEST(FBVector, move_iterator) {
+ fbvector<int> base = { 0, 1, 2 };
+
+ auto cp1 = base;
+ fbvector<int> fbvi1(std::make_move_iterator(cp1.begin()),
+ std::make_move_iterator(cp1.end()));
+ EXPECT_EQ(fbvi1, base);
+
+ auto cp2 = base;
+ fbvector<int> fbvi2;
+ fbvi2.assign(std::make_move_iterator(cp2.begin()),
+ std::make_move_iterator(cp2.end()));
+ EXPECT_EQ(fbvi2, base);
+
+ auto cp3 = base;
+ fbvector<int> fbvi3;
+ fbvi3.insert(fbvi3.end(),
+ std::make_move_iterator(cp3.begin()),
+ std::make_move_iterator(cp3.end()));
+ EXPECT_EQ(fbvi3, base);
+}
+
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
google::ParseCommandLineFlags(&argc, &argv, true);