summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/algorithms/alg.sorting
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2017-10-30 15:50:00 +0000
committerMarshall Clow <mclow.lists@gmail.com>2017-10-30 15:50:00 +0000
commit05da5b0205aeada52a6838353d214db3723c79c7 (patch)
tree2cc8e56888649ff4c4938cd9f475e40bdd6979c7 /libcxx/test/std/algorithms/alg.sorting
parent4e13d4de52783dbdf9268a01055b546f5176947c (diff)
downloadbcm5719-llvm-05da5b0205aeada52a6838353d214db3723c79c7.tar.gz
bcm5719-llvm-05da5b0205aeada52a6838353d214db3723c79c7.zip
Fix PR#35119 : set_union misbehaves with move_iterators. Thanks to Denis Yaroshevskiy for both the bug report and the fix.
llvm-svn: 316914
Diffstat (limited to 'libcxx/test/std/algorithms/alg.sorting')
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union_move.pass.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union_move.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union_move.pass.cpp
new file mode 100644
index 00000000000..aa5b8700961
--- /dev/null
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.set.operations/set.union/set_union_move.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<InputIterator InIter1, InputIterator InIter2, typename OutIter,
+// CopyConstructible Compare>
+// requires OutputIterator<OutIter, InIter1::reference>
+// && OutputIterator<OutIter, InIter2::reference>
+// && Predicate<Compare, InIter1::value_type, InIter2::value_type>
+// && Predicate<Compare, InIter2::value_type, InIter1::value_type>
+// OutIter
+// set_union(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
+// OutIter result, Compare comp);
+
+#include <algorithm>
+#include <cassert>
+#include <iterator>
+#include <vector>
+
+#include "MoveOnly.h"
+
+
+int main()
+{
+ std::vector<MoveOnly> lhs, rhs;
+ lhs.push_back(MoveOnly(2));
+ rhs.push_back(MoveOnly(2));
+
+ std::vector<MoveOnly> res;
+ std::set_union(std::make_move_iterator(lhs.begin()),
+ std::make_move_iterator(lhs.end()),
+ std::make_move_iterator(rhs.begin()),
+ std::make_move_iterator(rhs.end()), std::back_inserter(res));
+
+ assert(res.size() == 1);
+ assert(res[0].get() == 2);
+}
OpenPOWER on IntegriCloud