summaryrefslogtreecommitdiff
path: root/test/std/iterators
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/iterators')
-rw-r--r--test/std/iterators/iterator.container/data.pass.cpp74
-rw-r--r--test/std/iterators/iterator.container/empty.pass.cpp77
-rw-r--r--test/std/iterators/iterator.container/size.pass.cpp76
-rw-r--r--test/std/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp82
-rw-r--r--test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp45
-rw-r--r--test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp40
-rw-r--r--test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp46
-rw-r--r--test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp44
-rw-r--r--test/std/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp35
-rw-r--r--test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp38
-rw-r--r--test/std/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp43
-rw-r--r--test/std/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp35
-rw-r--r--test/std/iterators/iterator.primitives/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp24
-rw-r--r--test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp24
-rw-r--r--test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp22
-rw-r--r--test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp22
-rw-r--r--test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp24
-rw-r--r--test/std/iterators/iterator.range/begin-end.pass.cpp146
-rw-r--r--test/std/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterator.synopsis/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/iterators.general/gcc_workaround.pass.cpp20
-rw-r--r--test/std/iterators/iterators.general/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp24
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp31
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp46
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp35
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp59
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp24
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp31
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp47
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp41
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp35
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp60
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp31
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp85
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp98
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp35
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp64
-rw-r--r--test/std/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp46
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp39
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp46
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp46
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp38
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp44
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp34
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp31
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp39
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp39
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp58
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp31
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp61
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp39
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp47
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp56
-rw-r--r--test/std/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp33
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp31
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp35
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp38
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.make/make_reverse_iterator.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op!=/test.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp36
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp47
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp39
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp45
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp43
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp38
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp42
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp89
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp37
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp61
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp36
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.fail.cpp30
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp30
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp30
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp37
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp34
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp52
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp32
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp29
-rw-r--r--test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp56
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp41
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp42
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp36
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp50
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp78
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.cpp80
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp40
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp80
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp28
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp38
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp39
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp44
-rw-r--r--test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp60
-rw-r--r--test/std/iterators/stream.iterators/iterator.range/begin_array.pass.cpp24
-rw-r--r--test/std/iterators/stream.iterators/iterator.range/begin_const.pass.cpp23
-rw-r--r--test/std/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp25
-rw-r--r--test/std/iterators/stream.iterators/iterator.range/end_array.pass.cpp24
-rw-r--r--test/std/iterators/stream.iterators/iterator.range/end_const.pass.cpp23
-rw-r--r--test/std/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp23
-rw-r--r--test/std/iterators/stream.iterators/nothing_to_do.pass.cpp12
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp26
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp25
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp32
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp46
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp26
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp29
-rw-r--r--test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp40
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp32
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp32
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp39
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp34
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp30
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp39
-rw-r--r--test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp44
-rw-r--r--test/std/iterators/version.pass.cpp20
170 files changed, 6297 insertions, 0 deletions
diff --git a/test/std/iterators/iterator.container/data.pass.cpp b/test/std/iterators/iterator.container/data.pass.cpp
new file mode 100644
index 0000000000000..3d1fa33358dbb
--- /dev/null
+++ b/test/std/iterators/iterator.container/data.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+// template <class C> constexpr auto data(C& c) -> decltype(c.data()); // C++17
+// template <class C> constexpr auto data(const C& c) -> decltype(c.data()); // C++17
+// template <class T, size_t N> constexpr T* data(T (&array)[N]) noexcept; // C++17
+// template <class E> constexpr const E* data(initializer_list<E> il) noexcept; // C++17
+
+#if __cplusplus <= 201402L
+int main () {}
+#else
+
+#include <iterator>
+#include <cassert>
+#include <vector>
+#include <array>
+#include <initializer_list>
+
+template<typename C>
+void test_const_container( const C& c )
+{
+ assert ( std::data(c) == c.data());
+}
+
+template<typename T>
+void test_const_container( const std::initializer_list<T>& c )
+{
+ assert ( std::data(c) == c.begin());
+}
+
+template<typename C>
+void test_container( C& c )
+{
+ assert ( std::data(c) == c.data());
+}
+
+template<typename T>
+void test_container( std::initializer_list<T>& c)
+{
+ assert ( std::data(c) == c.begin());
+}
+
+template<typename T, size_t Sz>
+void test_const_array( const T (&array)[Sz] )
+{
+ assert ( std::data(array) == &array[0]);
+}
+
+int main()
+{
+ std::vector<int> v; v.push_back(1);
+ std::array<int, 1> a; a[0] = 3;
+ std::initializer_list<int> il = { 4 };
+
+ test_container ( v );
+ test_container ( a );
+ test_container ( il );
+
+ test_const_container ( v );
+ test_const_container ( a );
+ test_const_container ( il );
+
+ static constexpr int arrA [] { 1, 2, 3 };
+ test_const_array ( arrA );
+}
+
+#endif
diff --git a/test/std/iterators/iterator.container/empty.pass.cpp b/test/std/iterators/iterator.container/empty.pass.cpp
new file mode 100644
index 0000000000000..f26cb98e1aed6
--- /dev/null
+++ b/test/std/iterators/iterator.container/empty.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+// template <class C> constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17
+// template <class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept; // C++17
+// template <class E> constexpr bool empty(initializer_list<E> il) noexcept; // C++17
+
+#if __cplusplus <= 201402L
+int main () {}
+#else
+
+#include <iterator>
+#include <cassert>
+#include <vector>
+#include <array>
+#include <list>
+#include <initializer_list>
+
+template<typename C>
+void test_const_container( const C& c )
+{
+ assert ( std::empty(c) == c.empty());
+}
+
+template<typename T>
+void test_const_container( const std::initializer_list<T>& c )
+{
+ assert ( std::empty(c) == (c.size() == 0));
+}
+
+template<typename C>
+void test_container( C& c )
+{
+ assert ( std::empty(c) == c.empty());
+}
+
+template<typename T>
+void test_container( std::initializer_list<T>& c )
+{
+ assert ( std::empty(c) == (c.size() == 0));
+}
+
+template<typename T, size_t Sz>
+void test_const_array( const T (&array)[Sz] )
+{
+ assert (!std::empty(array));
+}
+
+int main()
+{
+ std::vector<int> v; v.push_back(1);
+ std::list<int> l; l.push_back(2);
+ std::array<int, 1> a; a[0] = 3;
+ std::initializer_list<int> il = { 4 };
+
+ test_container ( v );
+ test_container ( l );
+ test_container ( a );
+ test_container ( il );
+
+ test_const_container ( v );
+ test_const_container ( l );
+ test_const_container ( a );
+ test_const_container ( il );
+
+ static constexpr int arrA [] { 1, 2, 3 };
+ test_const_array ( arrA );
+}
+
+#endif
diff --git a/test/std/iterators/iterator.container/size.pass.cpp b/test/std/iterators/iterator.container/size.pass.cpp
new file mode 100644
index 0000000000000..705fb40e1926f
--- /dev/null
+++ b/test/std/iterators/iterator.container/size.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+// template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17
+// template <class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept; // C++17
+
+#if __cplusplus <= 201402L
+int main () {}
+#else
+
+#include <iterator>
+#include <cassert>
+#include <vector>
+#include <array>
+#include <list>
+#include <initializer_list>
+
+template<typename C>
+void test_const_container( const C& c )
+{
+ assert ( std::size(c) == c.size());
+}
+
+template<typename T>
+void test_const_container( const std::initializer_list<T>& c)
+{
+ assert ( std::size(c) == c.size());
+}
+
+template<typename C>
+void test_container( C& c)
+{
+ assert ( std::size(c) == c.size());
+}
+
+template<typename T>
+void test_container( std::initializer_list<T>& c )
+{
+ assert ( std::size(c) == c.size());
+}
+
+template<typename T, size_t Sz>
+void test_const_array( const T (&array)[Sz] )
+{
+ assert ( std::size(array) == Sz );
+}
+
+int main()
+{
+ std::vector<int> v; v.push_back(1);
+ std::list<int> l; l.push_back(2);
+ std::array<int, 1> a; a[0] = 3;
+ std::initializer_list<int> il = { 4 };
+
+ test_container ( v );
+ test_container ( l );
+ test_container ( a );
+ test_container ( il );
+
+ test_const_container ( v );
+ test_const_container ( l );
+ test_const_container ( a );
+ test_const_container ( il );
+
+ static constexpr int arrA [] { 1, 2, 3 };
+ test_const_array ( arrA );
+}
+
+#endif
diff --git a/test/std/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp b/test/std/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp
new file mode 100644
index 0000000000000..26d5c86602821
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.basic/iterator.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class Category, class T, class Distance = ptrdiff_t,
+// class Pointer = T*, class Reference = T&>
+// struct iterator
+// {
+// typedef T value_type;
+// typedef Distance difference_type;
+// typedef Pointer pointer;
+// typedef Reference reference;
+// typedef Category iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+template <class T>
+void
+test2()
+{
+ typedef std::iterator<std::forward_iterator_tag, T> It;
+ static_assert((std::is_same<typename It::value_type, T>::value), "");
+ static_assert((std::is_same<typename It::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<typename It::pointer, T*>::value), "");
+ static_assert((std::is_same<typename It::reference, T&>::value), "");
+ static_assert((std::is_same<typename It::iterator_category, std::forward_iterator_tag>::value), "");
+}
+
+template <class T>
+void
+test3()
+{
+ typedef std::iterator<std::bidirectional_iterator_tag, T, short> It;
+ static_assert((std::is_same<typename It::value_type, T>::value), "");
+ static_assert((std::is_same<typename It::difference_type, short>::value), "");
+ static_assert((std::is_same<typename It::pointer, T*>::value), "");
+ static_assert((std::is_same<typename It::reference, T&>::value), "");
+ static_assert((std::is_same<typename It::iterator_category, std::bidirectional_iterator_tag>::value), "");
+}
+
+template <class T>
+void
+test4()
+{
+ typedef std::iterator<std::random_access_iterator_tag, T, int, const T*> It;
+ static_assert((std::is_same<typename It::value_type, T>::value), "");
+ static_assert((std::is_same<typename It::difference_type, int>::value), "");
+ static_assert((std::is_same<typename It::pointer, const T*>::value), "");
+ static_assert((std::is_same<typename It::reference, T&>::value), "");
+ static_assert((std::is_same<typename It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
+
+template <class T>
+void
+test5()
+{
+ typedef std::iterator<std::input_iterator_tag, T, long, const T*, const T&> It;
+ static_assert((std::is_same<typename It::value_type, T>::value), "");
+ static_assert((std::is_same<typename It::difference_type, long>::value), "");
+ static_assert((std::is_same<typename It::pointer, const T*>::value), "");
+ static_assert((std::is_same<typename It::reference, const T&>::value), "");
+ static_assert((std::is_same<typename It::iterator_category, std::input_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test2<A>();
+ test3<A>();
+ test4<A>();
+ test5<A>();
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp b/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
new file mode 100644
index 0000000000000..e395da299dc7b
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InputIterator Iter>
+// void advance(Iter& i, Iter::difference_type n);
+//
+// template <BidirectionalIterator Iter>
+// void advance(Iter& i, Iter::difference_type n);
+//
+// template <RandomAccessIterator Iter>
+// void advance(Iter& i, Iter::difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ std::advance(i, n);
+ assert(i == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(input_iterator<const char*>(s), 10, input_iterator<const char*>(s+10));
+ test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10));
+ test(bidirectional_iterator<const char*>(s+5), 5, bidirectional_iterator<const char*>(s+10));
+ test(bidirectional_iterator<const char*>(s+5), -5, bidirectional_iterator<const char*>(s));
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+ test(random_access_iterator<const char*>(s+5), -5, random_access_iterator<const char*>(s));
+ test(s+5, 5, s+10);
+ test(s+5, -5, s);
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp b/test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
new file mode 100644
index 0000000000000..7fef635838c31
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InputIterator Iter>
+// Iter::difference_type
+// distance(Iter first, Iter last);
+//
+// template <RandomAccessIterator Iter>
+// Iter::difference_type
+// distance(Iter first, Iter last);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It first, It last, typename std::iterator_traits<It>::difference_type x)
+{
+ assert(std::distance(first, last) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(input_iterator<const char*>(s), input_iterator<const char*>(s+10), 10);
+ test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+10), 10);
+ test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+10), 10);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+10), 10);
+ test(s, s+10, 10);
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp b/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
new file mode 100644
index 0000000000000..f584110499b8b
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InputIterator Iter>
+// Iter next(Iter x, Iter::difference_type n = 1);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ assert(std::next(i, n) == x);
+}
+
+template <class It>
+void
+test(It i, It x)
+{
+ assert(std::next(i) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(forward_iterator<const char*>(s), 10, forward_iterator<const char*>(s+10));
+ test(bidirectional_iterator<const char*>(s), 10, bidirectional_iterator<const char*>(s+10));
+ test(random_access_iterator<const char*>(s), 10, random_access_iterator<const char*>(s+10));
+ test(s, 10, s+10);
+
+ test(forward_iterator<const char*>(s), forward_iterator<const char*>(s+1));
+ test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1));
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1));
+ test(s, s+1);
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp b/test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
new file mode 100644
index 0000000000000..0641706c928bb
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.operations/prev.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <BidirectionalIterator Iter>
+// Iter prev(Iter x, Iter::difference_type n = 1);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ assert(std::prev(i, n) == x);
+}
+
+template <class It>
+void
+test(It i, It x)
+{
+ assert(std::prev(i) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(bidirectional_iterator<const char*>(s+10), 10, bidirectional_iterator<const char*>(s));
+ test(random_access_iterator<const char*>(s+10), 10, random_access_iterator<const char*>(s));
+ test(s+10, 10, s);
+
+ test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
+ test(s+1, s);
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp b/test/std/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp
new file mode 100644
index 0000000000000..f40754fd9daf8
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.traits/const_pointer.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class T>
+// struct iterator_traits<const T*>
+// {
+// typedef ptrdiff_t difference_type;
+// typedef T value_type;
+// typedef const T* pointer;
+// typedef const T& reference;
+// typedef random_access_iterator_tag iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+ typedef std::iterator_traits<const A*> It;
+ static_assert((std::is_same<It::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<It::value_type, A>::value), "");
+ static_assert((std::is_same<It::pointer, const A*>::value), "");
+ static_assert((std::is_same<It::reference, const A&>::value), "");
+ static_assert((std::is_same<It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp b/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
new file mode 100644
index 0000000000000..e48e44b3777f1
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class NotAnIterator>
+// struct iterator_traits
+// {
+// };
+
+#include <iterator>
+
+struct not_an_iterator
+{
+};
+
+template <class _Tp>
+struct has_value_type
+{
+private:
+ struct two {char lx; char lxx;};
+ template <class _Up> static two test(...);
+ template <class _Up> static char test(typename _Up::value_type* = 0);
+public:
+ static const bool value = sizeof(test<_Tp>(0)) == 1;
+};
+
+int main()
+{
+ typedef std::iterator_traits<not_an_iterator> It;
+ static_assert(!(has_value_type<It>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp b/test/std/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp
new file mode 100644
index 0000000000000..38f7c0b6b833c
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.traits/iterator.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class Iter>
+// struct iterator_traits
+// {
+// typedef typename Iter::difference_type difference_type;
+// typedef typename Iter::value_type value_type;
+// typedef typename Iter::pointer pointer;
+// typedef typename Iter::reference reference;
+// typedef typename Iter::iterator_category iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+struct test_iterator
+{
+ typedef int difference_type;
+ typedef A value_type;
+ typedef A* pointer;
+ typedef A& reference;
+ typedef std::forward_iterator_tag iterator_category;
+};
+
+int main()
+{
+ typedef std::iterator_traits<test_iterator> It;
+ static_assert((std::is_same<It::difference_type, int>::value), "");
+ static_assert((std::is_same<It::value_type, A>::value), "");
+ static_assert((std::is_same<It::pointer, A*>::value), "");
+ static_assert((std::is_same<It::iterator_category, std::forward_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp b/test/std/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp
new file mode 100644
index 0000000000000..5a8fe60774eeb
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/iterator.traits/pointer.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class T>
+// struct iterator_traits<T*>
+// {
+// typedef ptrdiff_t difference_type;
+// typedef T value_type;
+// typedef T* pointer;
+// typedef T& reference;
+// typedef random_access_iterator_tag iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+ typedef std::iterator_traits<A*> It;
+ static_assert((std::is_same<It::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<It::value_type, A>::value), "");
+ static_assert((std::is_same<It::pointer, A*>::value), "");
+ static_assert((std::is_same<It::reference, A&>::value), "");
+ static_assert((std::is_same<It::iterator_category, std::random_access_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/nothing_to_do.pass.cpp b/test/std/iterators/iterator.primitives/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp b/test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp
new file mode 100644
index 0000000000000..0f368c3b765f5
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct bidirectional_iterator_tag : public forward_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ std::bidirectional_iterator_tag tag;
+ static_assert((std::is_base_of<std::forward_iterator_tag,
+ std::bidirectional_iterator_tag>::value), "");
+ static_assert((!std::is_base_of<std::output_iterator_tag,
+ std::bidirectional_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp b/test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp
new file mode 100644
index 0000000000000..0936595c85d6b
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct forward_iterator_tag: public input_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ std::forward_iterator_tag tag;
+ static_assert((std::is_base_of<std::input_iterator_tag,
+ std::forward_iterator_tag>::value), "");
+ static_assert((!std::is_base_of<std::output_iterator_tag,
+ std::forward_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp b/test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp
new file mode 100644
index 0000000000000..afeac3e91caeb
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct input_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ std::input_iterator_tag tag;
+ static_assert((!std::is_base_of<std::output_iterator_tag,
+ std::input_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp b/test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp
new file mode 100644
index 0000000000000..7f7f66a98f4ad
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct output_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ std::output_iterator_tag tag;
+ static_assert((!std::is_base_of<std::input_iterator_tag,
+ std::output_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp b/test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp
new file mode 100644
index 0000000000000..04f830bc31090
--- /dev/null
+++ b/test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// struct random_access_iterator_tag : public bidirectional_iterator_tag {};
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ std::random_access_iterator_tag tag;
+ static_assert((std::is_base_of<std::bidirectional_iterator_tag,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((!std::is_base_of<std::output_iterator_tag,
+ std::random_access_iterator_tag>::value), "");
+}
diff --git a/test/std/iterators/iterator.range/begin-end.pass.cpp b/test/std/iterators/iterator.range/begin-end.pass.cpp
new file mode 100644
index 0000000000000..bd7e0aa90fbc1
--- /dev/null
+++ b/test/std/iterators/iterator.range/begin-end.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+// template <class C> auto begin(C& c) -> decltype(c.begin());
+// template <class C> auto begin(const C& c) -> decltype(c.begin());
+// template <class C> auto end(C& c) -> decltype(c.end());
+// template <class C> auto end(const C& c) -> decltype(c.end());
+// template <class E> reverse_iterator<const E*> rbegin(initializer_list<E> il);
+// template <class E> reverse_iterator<const E*> rend(initializer_list<E> il);
+
+#if __cplusplus >= 201103L
+#include <iterator>
+#include <cassert>
+#include <vector>
+#include <array>
+#include <list>
+#include <initializer_list>
+
+template<typename C>
+void test_const_container( const C & c, typename C::value_type val ) {
+ assert ( std::begin(c) == c.begin());
+ assert (*std::begin(c) == val );
+ assert ( std::begin(c) != c.end());
+ assert ( std::end(c) == c.end());
+#if _LIBCPP_STD_VER > 11
+ assert ( std::cbegin(c) == c.cbegin());
+ assert ( std::cbegin(c) != c.cend());
+ assert ( std::cend(c) == c.cend());
+ assert ( std::rbegin(c) == c.rbegin());
+ assert ( std::rbegin(c) != c.rend());
+ assert ( std::rend(c) == c.rend());
+ assert ( std::crbegin(c) == c.crbegin());
+ assert ( std::crbegin(c) != c.crend());
+ assert ( std::crend(c) == c.crend());
+#endif
+ }
+
+template<typename T>
+void test_const_container( const std::initializer_list<T> & c, T val ) {
+ assert ( std::begin(c) == c.begin());
+ assert (*std::begin(c) == val );
+ assert ( std::begin(c) != c.end());
+ assert ( std::end(c) == c.end());
+#if _LIBCPP_STD_VER > 11
+// initializer_list doesn't have cbegin/cend/rbegin/rend
+// but std::cbegin(),etc work (b/c they're general fn templates)
+// assert ( std::cbegin(c) == c.cbegin());
+// assert ( std::cbegin(c) != c.cend());
+// assert ( std::cend(c) == c.cend());
+// assert ( std::rbegin(c) == c.rbegin());
+// assert ( std::rbegin(c) != c.rend());
+// assert ( std::rend(c) == c.rend());
+// assert ( std::crbegin(c) == c.crbegin());
+// assert ( std::crbegin(c) != c.crend());
+// assert ( std::crend(c) == c.crend());
+#endif
+ }
+
+template<typename C>
+void test_container( C & c, typename C::value_type val ) {
+ assert ( std::begin(c) == c.begin());
+ assert (*std::begin(c) == val );
+ assert ( std::begin(c) != c.end());
+ assert ( std::end(c) == c.end());
+#if _LIBCPP_STD_VER > 11
+ assert ( std::cbegin(c) == c.cbegin());
+ assert ( std::cbegin(c) != c.cend());
+ assert ( std::cend(c) == c.cend());
+ assert ( std::rbegin(c) == c.rbegin());
+ assert ( std::rbegin(c) != c.rend());
+ assert ( std::rend(c) == c.rend());
+ assert ( std::crbegin(c) == c.crbegin());
+ assert ( std::crbegin(c) != c.crend());
+ assert ( std::crend(c) == c.crend());
+#endif
+ }
+
+template<typename T>
+void test_container( std::initializer_list<T> & c, T val ) {
+ assert ( std::begin(c) == c.begin());
+ assert (*std::begin(c) == val );
+ assert ( std::begin(c) != c.end());
+ assert ( std::end(c) == c.end());
+#if _LIBCPP_STD_VER > 11
+// initializer_list doesn't have cbegin/cend/rbegin/rend
+// assert ( std::cbegin(c) == c.cbegin());
+// assert ( std::cbegin(c) != c.cend());
+// assert ( std::cend(c) == c.cend());
+// assert ( std::rbegin(c) == c.rbegin());
+// assert ( std::rbegin(c) != c.rend());
+// assert ( std::rend(c) == c.rend());
+// assert ( std::crbegin(c) == c.crbegin());
+// assert ( std::crbegin(c) != c.crend());
+// assert ( std::crend(c) == c.crend());
+#endif
+ }
+
+template<typename T, size_t Sz>
+void test_const_array( const T (&array)[Sz] ) {
+ assert ( std::begin(array) == array );
+ assert (*std::begin(array) == array[0] );
+ assert ( std::begin(array) != std::end(array));
+ assert ( std::end(array) == array + Sz);
+#if _LIBCPP_STD_VER > 11
+ assert ( std::cbegin(array) == array );
+ assert (*std::cbegin(array) == array[0] );
+ assert ( std::cbegin(array) != std::cend(array));
+ assert ( std::cend(array) == array + Sz);
+#endif
+ }
+
+int main(){
+ std::vector<int> v; v.push_back(1);
+ std::list<int> l; l.push_back(2);
+ std::array<int, 1> a; a[0] = 3;
+ std::initializer_list<int> il = { 4 };
+
+ test_container ( v, 1 );
+ test_container ( l, 2 );
+ test_container ( a, 3 );
+ test_container ( il, 4 );
+
+ test_const_container ( v, 1 );
+ test_const_container ( l, 2 );
+ test_const_container ( a, 3 );
+ test_const_container ( il, 4 );
+
+ static constexpr int arrA [] { 1, 2, 3 };
+ test_const_array ( arrA );
+#if _LIBCPP_STD_VER > 11
+ constexpr const int *b = std::cbegin(arrA);
+ constexpr const int *e = std::cend(arrA);
+ static_assert(e - b == 3, "");
+#endif
+}
+
+#else
+int main(){}
+#endif
diff --git a/test/std/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/bidirectional.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/forward.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/input.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/iterator.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/iterator.requirements.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/output.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp b/test/std/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/iterator.requirements/random.access.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterator.synopsis/nothing_to_do.pass.cpp b/test/std/iterators/iterator.synopsis/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/iterator.synopsis/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/iterators.general/gcc_workaround.pass.cpp b/test/std/iterators/iterators.general/gcc_workaround.pass.cpp
new file mode 100644
index 0000000000000..6522bd3c7bcb6
--- /dev/null
+++ b/test/std/iterators/iterators.general/gcc_workaround.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// Tests workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64816.
+
+#include <string>
+
+void f(const std::string &s) { s.begin(); }
+
+#include <vector>
+
+void AppendTo(const std::vector<char> &v) { v.begin(); }
+
+int main() {}
diff --git a/test/std/iterators/iterators.general/nothing_to_do.pass.cpp b/test/std/iterators/iterators.general/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/iterators.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp
new file mode 100644
index 0000000000000..5dd49a6254e79
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// explicit back_insert_iterator(Cont& x);
+
+// test for explicit
+
+#include <iterator>
+#include <vector>
+
+int main()
+{
+ std::back_insert_iterator<std::vector<int> > i = std::vector<int>();
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp
new file mode 100644
index 0000000000000..f280adb7351a0
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.cons/container.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// explicit back_insert_iterator(Cont& x);
+
+#include <iterator>
+#include <vector>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::back_insert_iterator<C> i(c);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp
new file mode 100644
index 0000000000000..c6ff0473ffbc0
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/post.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// back_insert_iterator<Cont> operator++(int);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::back_insert_iterator<C> i(c);
+ std::back_insert_iterator<C> r = i++;
+ r = 0;
+ assert(c.size() == 1);
+ assert(c.back() == 0);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp
new file mode 100644
index 0000000000000..2b9f245a05a0c
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op++/pre.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// back_insert_iterator<Cont>& operator++();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::back_insert_iterator<C> i(c);
+ std::back_insert_iterator<C>& r = ++i;
+ assert(&r == &i);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp
new file mode 100644
index 0000000000000..d3d1fbbcb9dee
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+// back_insert_iterator<Cont>&
+// operator=(const Cont::value_type& value);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+ const typename C::value_type v = typename C::value_type();
+ std::back_insert_iterator<C> i(c);
+ i = v;
+ assert(c.back() == v);
+}
+
+class Copyable
+{
+ int data_;
+public:
+ Copyable() : data_(0) {}
+ ~Copyable() {data_ = -1;}
+
+ friend bool operator==(const Copyable& x, const Copyable& y)
+ {return x.data_ == y.data_;}
+};
+
+int main()
+{
+ test(std::vector<Copyable>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp
new file mode 100644
index 0000000000000..a3c11f7881a9b
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/rv_value.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+// back_insert_iterator<Cont>&
+// operator=(Cont::value_type&& value);
+
+#include <iterator>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include <vector>
+#include <memory>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+ std::back_insert_iterator<C> i(c);
+ i = typename C::value_type();
+ assert(c.back() == typename C::value_type());
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(std::vector<std::unique_ptr<int> >());
+#endif
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp
new file mode 100644
index 0000000000000..f50f309e69123
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op_astrk/test.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// back_insert_iterator<Cont>& operator*();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::back_insert_iterator<C> i(c);
+ std::back_insert_iterator<C>& r = *i;
+ assert(&r == &i);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp
new file mode 100644
index 0000000000000..30e41407e6a53
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.inserter/test.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <BackInsertionContainer Cont>
+// back_insert_iterator<Cont>
+// back_inserter(Cont& x);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::back_insert_iterator<C> i = std::back_inserter(c);
+ i = 0;
+ assert(c.size() == 1);
+ assert(c.back() == 0);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp
new file mode 100644
index 0000000000000..2611c9a4b0cc5
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/types.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// back_insert_iterator
+
+// Test nested types and data member:
+
+// template <BackInsertionContainer Cont>
+// class back_insert_iterator {
+// protected:
+// Cont* container;
+// public:
+// typedef Cont container_type;
+// typedef void value_type;
+// typedef void difference_type;
+// typedef back_insert_iterator<Cont>& reference;
+// typedef void pointer;
+// };
+
+#include <iterator>
+#include <type_traits>
+#include <vector>
+
+template <class C>
+struct find_container
+ : private std::back_insert_iterator<C>
+{
+ explicit find_container(C& c) : std::back_insert_iterator<C>(c) {}
+ void test() {this->container = 0;}
+};
+
+template <class C>
+void
+test()
+{
+ typedef std::back_insert_iterator<C> R;
+ C c;
+ find_container<C> q(c);
+ q.test();
+ static_assert((std::is_same<typename R::container_type, C>::value), "");
+ static_assert((std::is_same<typename R::value_type, void>::value), "");
+ static_assert((std::is_same<typename R::difference_type, void>::value), "");
+ static_assert((std::is_same<typename R::reference, R&>::value), "");
+ static_assert((std::is_same<typename R::pointer, void>::value), "");
+ static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test<std::vector<int> >();
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp
new file mode 100644
index 0000000000000..96d5d000d5bf2
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.fail.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// explicit front_insert_iterator(Cont& x);
+
+// test for explicit
+
+#include <iterator>
+#include <list>
+
+int main()
+{
+ std::front_insert_iterator<std::list<int> > i = std::list<int>();
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp
new file mode 100644
index 0000000000000..1a148e613cba9
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.cons/container.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// explicit front_insert_iterator(Cont& x);
+
+#include <iterator>
+#include <list>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::front_insert_iterator<C> i(c);
+}
+
+int main()
+{
+ test(std::list<int>());
+ test(nasty_list<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp
new file mode 100644
index 0000000000000..74892272e245b
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/post.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont> operator++(int);
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::front_insert_iterator<C> i(c);
+ std::front_insert_iterator<C> r = i++;
+ r = 0;
+ assert(c.size() == 1);
+ assert(c.back() == 0);
+}
+
+int main()
+{
+ test(std::list<int>());
+ test(nasty_list<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp
new file mode 100644
index 0000000000000..e6d6c07604ef1
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op++/pre.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>& operator++();
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::front_insert_iterator<C> i(c);
+ std::front_insert_iterator<C>& r = ++i;
+ assert(&r == &i);
+}
+
+int main()
+{
+ test(std::list<int>());
+ test(nasty_list<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp
new file mode 100644
index 0000000000000..cdca9bf4becba
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>&
+// operator=(const Cont::value_type& value);
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ const typename C::value_type v = typename C::value_type();
+ std::front_insert_iterator<C> i(c);
+ i = v;
+ assert(c.front() == v);
+}
+
+class Copyable
+{
+ int data_;
+public:
+ Copyable() : data_(0) {}
+ ~Copyable() {data_ = -1;}
+
+ friend bool operator==(const Copyable& x, const Copyable& y)
+ {return x.data_ == y.data_;}
+};
+
+int main()
+{
+ test(std::list<Copyable>());
+ test(nasty_list<Copyable>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp
new file mode 100644
index 0000000000000..bd2bd44837ab9
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/rv_value.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>&
+// operator=(Cont::value_type&& value);
+
+#include <iterator>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include <list>
+#include <memory>
+#include <cassert>
+
+template <class C>
+void
+test(C c)
+{
+ std::front_insert_iterator<C> i(c);
+ i = typename C::value_type();
+ assert(c.front() == typename C::value_type());
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(std::list<std::unique_ptr<int> >());
+#endif
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp
new file mode 100644
index 0000000000000..1ff49dde4512b
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op_astrk/test.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// front_insert_iterator<Cont>& operator*();
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::front_insert_iterator<C> i(c);
+ std::front_insert_iterator<C>& r = *i;
+ assert(&r == &i);
+}
+
+int main()
+{
+ test(std::list<int>());
+ test(nasty_list<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp
new file mode 100644
index 0000000000000..c18f84baf5f47
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.inserter/test.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <BackInsertionContainer Cont>
+// front_insert_iterator<Cont>
+// front_inserter(Cont& x);
+
+#include <iterator>
+#include <list>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::front_insert_iterator<C> i = std::front_inserter(c);
+ i = 0;
+ assert(c.size() == 1);
+ assert(c.front() == 0);
+}
+
+int main()
+{
+ test(std::list<int>());
+ test(nasty_list<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp
new file mode 100644
index 0000000000000..755133a919481
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/types.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// front_insert_iterator
+
+// Test nested types and data member:
+
+// template <class Container>
+// class front_insert_iterator {
+// protected:
+// Container* container;
+// public:
+// typedef Container container_type;
+// typedef void value_type;
+// typedef void difference_type;
+// typedef front_insert_iterator<Cont>& reference;
+// typedef void pointer;
+// typedef output_iterator_tag iterator_category;
+// };
+
+#include <iterator>
+#include <type_traits>
+#include <vector>
+
+template <class C>
+struct find_container
+ : private std::front_insert_iterator<C>
+{
+ explicit find_container(C& c) : std::front_insert_iterator<C>(c) {}
+ void test() {this->container = 0;}
+};
+
+template <class C>
+void
+test()
+{
+ typedef std::front_insert_iterator<C> R;
+ C c;
+ find_container<C> q(c);
+ q.test();
+ static_assert((std::is_same<typename R::container_type, C>::value), "");
+ static_assert((std::is_same<typename R::value_type, void>::value), "");
+ static_assert((std::is_same<typename R::difference_type, void>::value), "");
+ static_assert((std::is_same<typename R::reference, R&>::value), "");
+ static_assert((std::is_same<typename R::pointer, void>::value), "");
+ static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test<std::vector<int> >();
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp
new file mode 100644
index 0000000000000..9f17240a72be2
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.cons/test.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator(Cont& x, Cont::iterator i);
+
+#include <iterator>
+#include <vector>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::insert_iterator<C> i(c, c.begin());
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp
new file mode 100644
index 0000000000000..7d81a7b721d1c
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/post.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator<Cont> operator++(int);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::insert_iterator<C> i(c, c.end());
+ std::insert_iterator<C> r = i++;
+ r = 0;
+ assert(c.size() == 1);
+ assert(c.back() == 0);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp
new file mode 100644
index 0000000000000..08e6ced01c6f4
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op++/pre.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator<Cont>& operator++();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::insert_iterator<C> i(c, c.end());
+ std::insert_iterator<C>& r = ++i;
+ assert(&r == &i);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp
new file mode 100644
index 0000000000000..01eb35efc6734
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/lv_value.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+// insert_iterator<Cont>&
+// operator=(const Cont::value_type& value);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c1, typename C::difference_type j,
+ typename C::value_type x1, typename C::value_type x2,
+ typename C::value_type x3, const C& c2)
+{
+ std::insert_iterator<C> q(c1, c1.begin() + j);
+ q = x1;
+ q = x2;
+ q = x3;
+ assert(c1 == c2);
+}
+
+template <class C>
+void
+insert3at(C& c, typename C::iterator i,
+ typename C::value_type x1, typename C::value_type x2,
+ typename C::value_type x3)
+{
+ i = c.insert(i, x1);
+ i = c.insert(++i, x2);
+ c.insert(++i, x3);
+}
+
+int main()
+{
+ {
+ typedef std::vector<int> C;
+ C c1;
+ for (int i = 0; i < 3; ++i)
+ c1.push_back(i);
+ C c2 = c1;
+ insert3at(c2, c2.begin(), 'a', 'b', 'c');
+ test(c1, 0, 'a', 'b', 'c', c2);
+ c2 = c1;
+ insert3at(c2, c2.begin()+1, 'a', 'b', 'c');
+ test(c1, 1, 'a', 'b', 'c', c2);
+ c2 = c1;
+ insert3at(c2, c2.begin()+2, 'a', 'b', 'c');
+ test(c1, 2, 'a', 'b', 'c', c2);
+ c2 = c1;
+ insert3at(c2, c2.begin()+3, 'a', 'b', 'c');
+ test(c1, 3, 'a', 'b', 'c', c2);
+ }
+ {
+ typedef nasty_vector<int> C;
+ C c1;
+ for (int i = 0; i < 3; ++i)
+ c1.push_back(i);
+ C c2 = c1;
+ insert3at(c2, c2.begin(), 'a', 'b', 'c');
+ test(c1, 0, 'a', 'b', 'c', c2);
+ c2 = c1;
+ insert3at(c2, c2.begin()+1, 'a', 'b', 'c');
+ test(c1, 1, 'a', 'b', 'c', c2);
+ c2 = c1;
+ insert3at(c2, c2.begin()+2, 'a', 'b', 'c');
+ test(c1, 2, 'a', 'b', 'c', c2);
+ c2 = c1;
+ insert3at(c2, c2.begin()+3, 'a', 'b', 'c');
+ test(c1, 3, 'a', 'b', 'c', c2);
+ }
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp
new file mode 100644
index 0000000000000..f771688f1adc2
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op=/rv_value.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// requires CopyConstructible<Cont::value_type>
+// insert_iterator<Cont>&
+// operator=(const Cont::value_type& value);
+
+#include <iterator>
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <utility>
+#include <vector>
+#include <memory>
+#include <cassert>
+
+template <class C>
+void
+test(C c1, typename C::difference_type j,
+ typename C::value_type x1, typename C::value_type x2,
+ typename C::value_type x3, const C& c2)
+{
+ std::insert_iterator<C> q(c1, c1.begin() + j);
+ q = std::move(x1);
+ q = std::move(x2);
+ q = std::move(x3);
+ assert(c1 == c2);
+}
+
+template <class C>
+void
+insert3at(C& c, typename C::iterator i,
+ typename C::value_type x1, typename C::value_type x2,
+ typename C::value_type x3)
+{
+ i = c.insert(i, std::move(x1));
+ i = c.insert(++i, std::move(x2));
+ c.insert(++i, std::move(x3));
+}
+
+struct do_nothing
+{
+ void operator()(void*) const {}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unique_ptr<int, do_nothing> Ptr;
+ typedef std::vector<Ptr> C;
+ C c1;
+ int x[6] = {0};
+ for (int i = 0; i < 3; ++i)
+ c1.push_back(Ptr(x+i));
+ C c2;
+ for (int i = 0; i < 3; ++i)
+ c2.push_back(Ptr(x+i));
+ insert3at(c2, c2.begin(), Ptr(x+3), Ptr(x+4), Ptr(x+5));
+ test(std::move(c1), 0, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+ c1.clear();
+ for (int i = 0; i < 3; ++i)
+ c1.push_back(Ptr(x+i));
+ c2.clear();
+ for (int i = 0; i < 3; ++i)
+ c2.push_back(Ptr(x+i));
+ insert3at(c2, c2.begin()+1, Ptr(x+3), Ptr(x+4), Ptr(x+5));
+ test(std::move(c1), 1, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+ c1.clear();
+ for (int i = 0; i < 3; ++i)
+ c1.push_back(Ptr(x+i));
+ c2.clear();
+ for (int i = 0; i < 3; ++i)
+ c2.push_back(Ptr(x+i));
+ insert3at(c2, c2.begin()+2, Ptr(x+3), Ptr(x+4), Ptr(x+5));
+ test(std::move(c1), 2, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+ c1.clear();
+ for (int i = 0; i < 3; ++i)
+ c1.push_back(Ptr(x+i));
+ c2.clear();
+ for (int i = 0; i < 3; ++i)
+ c2.push_back(Ptr(x+i));
+ insert3at(c2, c2.begin()+3, Ptr(x+3), Ptr(x+4), Ptr(x+5));
+ test(std::move(c1), 3, Ptr(x+3), Ptr(x+4), Ptr(x+5), c2);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp
new file mode 100644
index 0000000000000..1a926b5485cda
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/insert.iter.op_astrk/test.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// insert_iterator<Cont>& operator*();
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::insert_iterator<C> i(c, c.end());
+ std::insert_iterator<C>& r = *i;
+ assert(&r == &i);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp
new file mode 100644
index 0000000000000..43f28d09bcfab
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/inserter/test.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <InsertionContainer Cont>
+// insert_iterator<Cont>
+// inserter(Cont& x, Cont::iterator i);
+
+#include <iterator>
+#include <vector>
+#include <cassert>
+#include "nasty_containers.hpp"
+
+template <class C>
+void
+test(C c)
+{
+ std::insert_iterator<C> i = std::inserter(c, c.end());
+ i = 0;
+ assert(c.size() == 1);
+ assert(c.back() == 0);
+}
+
+int main()
+{
+ test(std::vector<int>());
+ test(nasty_vector<int>());
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp
new file mode 100644
index 0000000000000..cf63df63e89bc
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// insert_iterator
+
+// Test nested types and data members:
+
+// template <InsertionContainer Cont>
+// class insert_iterator {
+// protected:
+// Cont* container;
+// Cont::iterator iter;
+// public:
+// typedef Cont container_type;
+// typedef void value_type;
+// typedef void difference_type;
+// typedef insert_iterator<Cont>& reference;
+// typedef void pointer;
+// };
+
+#include <iterator>
+#include <type_traits>
+#include <vector>
+
+template <class C>
+struct find_members
+ : private std::insert_iterator<C>
+{
+ explicit find_members(C& c) : std::insert_iterator<C>(c, c.begin()) {}
+ void test()
+ {
+ this->container = 0;
+ (void)(this->iter == this->iter);
+ }
+};
+
+template <class C>
+void
+test()
+{
+ typedef std::insert_iterator<C> R;
+ C c;
+ find_members<C> q(c);
+ q.test();
+ static_assert((std::is_same<typename R::container_type, C>::value), "");
+ static_assert((std::is_same<typename R::value_type, void>::value), "");
+ static_assert((std::is_same<typename R::difference_type, void>::value), "");
+ static_assert((std::is_same<typename R::reference, R&>::value), "");
+ static_assert((std::is_same<typename R::pointer, void>::value), "");
+ static_assert((std::is_same<typename R::iterator_category, std::output_iterator_tag>::value), "");
+}
+
+int main()
+{
+ test<std::vector<int> >();
+}
diff --git a/test/std/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/insert.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp
new file mode 100644
index 0000000000000..06834981ef381
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <InputIterator Iter>
+// move_iterator<Iter>
+// make_move_iterator(const Iter& i);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i)
+{
+ const std::move_iterator<It> r(i);
+ assert(std::make_move_iterator(i) == r);
+}
+
+int main()
+{
+ {
+ char s[] = "1234567890";
+ test(input_iterator<char*>(s+5));
+ test(forward_iterator<char*>(s+5));
+ test(bidirectional_iterator<char*>(s+5));
+ test(random_access_iterator<char*>(s+5));
+ test(s+5);
+ }
+ {
+ int a[] = {1,2,3,4};
+ std::make_move_iterator(a+4);
+ std::make_move_iterator(a); // test for LWG issue 2061
+ }
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp
new file mode 100644
index 0000000000000..d52175c922962
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/minus.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasMinus<Iter1, Iter2>
+// auto
+// operator-(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y)
+// -> decltype(x.base() - y.base());
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, typename std::iterator_traits<It>::difference_type x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert(r1 - r2 == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s+5), random_access_iterator<char*>(s), 5);
+ test(s+5, s, 5);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp
new file mode 100644
index 0000000000000..e67ebfca37174
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/plus.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter>
+// move_iterator<Iter>
+// operator+(Iter::difference_type n, const move_iterator<Iter>& x);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ const std::move_iterator<It> r(i);
+ std::move_iterator<It> rr = n + r;
+ assert(rr.base() == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s+5), 5, random_access_iterator<char*>(s+10));
+ test(s+5, 5, s+10);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp
new file mode 100644
index 0000000000000..e9a19f4932c57
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+/difference_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+// move_iterator operator+(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ const std::move_iterator<It> r(i);
+ std::move_iterator<It> rr = r + n;
+ assert(rr.base() == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+ test(s+5, 5, s+10);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp
new file mode 100644
index 0000000000000..5de1bccf877ff
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.+=/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+// move_iterator& operator+=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ std::move_iterator<It> r(i);
+ std::move_iterator<It>& rr = r += n;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+ test(s+5, 5, s+10);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp
new file mode 100644
index 0000000000000..852f76a4a4d3d
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-/difference_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+// move_iterator operator-(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ const std::move_iterator<It> r(i);
+ std::move_iterator<It> rr = r - n;
+ assert(rr.base() == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+ test(s+5, 5, s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp
new file mode 100644
index 0000000000000..f8630736980de
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.-=/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+// move_iterator& operator-=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ std::move_iterator<It> r(i);
+ std::move_iterator<It>& rr = r -= n;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+ test(s+5, 5, s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp
new file mode 100644
index 0000000000000..fb4f0fa1dc12d
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_eq.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <InputIterator Iter1, InputIterator Iter2>
+// requires HasEqualTo<Iter1, Iter2>
+// bool
+// operator==(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert((r1 == r2) == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(input_iterator<char*>(s), input_iterator<char*>(s), true);
+ test(input_iterator<char*>(s), input_iterator<char*>(s+1), false);
+ test(forward_iterator<char*>(s), forward_iterator<char*>(s), true);
+ test(forward_iterator<char*>(s), forward_iterator<char*>(s+1), false);
+ test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s), true);
+ test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1), false);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
+ test(s, s, true);
+ test(s, s+1, false);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp
new file mode 100644
index 0000000000000..0edd2857c081a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasLess<Iter2, Iter1>
+// bool
+// operator>(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert((r1 > r2) == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
+ test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), true);
+ test(s, s, false);
+ test(s, s+1, false);
+ test(s+1, s, true);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp
new file mode 100644
index 0000000000000..cb9cdb9aeb4f7
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gte.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasLess<Iter1, Iter2>
+// bool
+// operator>=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert((r1 >= r2) == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
+ test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), true);
+ test(s, s, true);
+ test(s, s+1, false);
+ test(s+1, s, true);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp
new file mode 100644
index 0000000000000..e7979ddd746ed
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lt.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasLess<Iter1, Iter2>
+// bool
+// operator<(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert((r1 < r2) == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
+ test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), false);
+ test(s, s, false);
+ test(s, s+1, true);
+ test(s+1, s, false);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp
new file mode 100644
index 0000000000000..97a7bfdee4664
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_lte.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasLess<Iter2, Iter1>
+// bool
+// operator<=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert((r1 <= r2) == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
+ test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), false);
+ test(s, s, true);
+ test(s, s+1, true);
+ test(s+1, s, false);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp
new file mode 100644
index 0000000000000..9e4b9e37202c9
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_neq.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <InputIterator Iter1, InputIterator Iter2>
+// requires HasEqualTo<Iter1, Iter2>
+// bool
+// operator!=(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::move_iterator<It> r1(l);
+ const std::move_iterator<It> r2(r);
+ assert((r1 != r2) == x);
+}
+
+int main()
+{
+ char s[] = "1234567890";
+ test(input_iterator<char*>(s), input_iterator<char*>(s), false);
+ test(input_iterator<char*>(s), input_iterator<char*>(s+1), true);
+ test(forward_iterator<char*>(s), forward_iterator<char*>(s), false);
+ test(forward_iterator<char*>(s), forward_iterator<char*>(s+1), true);
+ test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s), false);
+ test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1), true);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), true);
+ test(s, s, false);
+ test(s, s+1, true);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp
new file mode 100644
index 0000000000000..22d267af94d99
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U>
+// requires HasConstructor<Iter, const U&>
+// move_iterator(const move_iterator<U> &u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+ std::move_iterator<U> r2(u);
+ std::move_iterator<It> r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+ derived d;
+
+ test<base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.pass.cpp
new file mode 100644
index 0000000000000..8c73a7d5c93c1
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/convert.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U>
+// requires HasConstructor<Iter, const U&>
+// move_iterator(const move_iterator<U> &u);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+ const std::move_iterator<U> r2(u);
+ std::move_iterator<It> r1 = r2;
+ assert(r1.base() == u);
+}
+
+struct Base {};
+struct Derived : Base {};
+
+int main()
+{
+ Derived d;
+
+ test<input_iterator<Base*> >(input_iterator<Derived*>(&d));
+ test<forward_iterator<Base*> >(forward_iterator<Derived*>(&d));
+ test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
+ test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
+ test<Base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp
new file mode 100644
index 0000000000000..782cb60203260
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/default.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator();
+
+#include <iterator>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test()
+{
+ std::move_iterator<It> r;
+}
+
+int main()
+{
+ test<input_iterator<char*> >();
+ test<forward_iterator<char*> >();
+ test<bidirectional_iterator<char*> >();
+ test<random_access_iterator<char*> >();
+ test<char*>();
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp
new file mode 100644
index 0000000000000..188acff69edb8
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.fail.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// explicit move_iterator(Iter );
+
+// test explicit
+
+#include <iterator>
+
+template <class It>
+void
+test(It i)
+{
+ std::move_iterator<It> r = i;
+}
+
+int main()
+{
+ char s[] = "123";
+ test(s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp
new file mode 100644
index 0000000000000..4a4a06018377d
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.const/iter.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// explicit move_iterator(Iter i);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i)
+{
+ std::move_iterator<It> r(i);
+ assert(r.base() == i);
+}
+
+int main()
+{
+ char s[] = "123";
+ test(input_iterator<char*>(s));
+ test(forward_iterator<char*>(s));
+ test(bidirectional_iterator<char*>(s));
+ test(random_access_iterator<char*>(s));
+ test(s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.conv/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp
new file mode 100644
index 0000000000000..26fab5be79310
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/post.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator operator--(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::move_iterator<It> r(i);
+ std::move_iterator<It> rr = r--;
+ assert(r.base() == x);
+ assert(rr.base() == i);
+}
+
+int main()
+{
+ char s[] = "123";
+ test(bidirectional_iterator<char*>(s+1), bidirectional_iterator<char*>(s));
+ test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s));
+ test(s+1, s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp
new file mode 100644
index 0000000000000..700b3b6377498
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator& operator--();
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::move_iterator<It> r(i);
+ std::move_iterator<It>& rr = --r;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ char s[] = "123";
+ test(bidirectional_iterator<char*>(s+1), bidirectional_iterator<char*>(s));
+ test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s));
+ test(s+1, s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
new file mode 100644
index 0000000000000..e7c13b5796221
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/post.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator operator++(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::move_iterator<It> r(i);
+ std::move_iterator<It> rr = r++;
+ assert(r.base() == x);
+ assert(rr.base() == i);
+}
+
+int main()
+{
+ char s[] = "123";
+ test(input_iterator<char*>(s), input_iterator<char*>(s+1));
+ test(forward_iterator<char*>(s), forward_iterator<char*>(s+1));
+ test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1));
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1));
+ test(s, s+1);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp
new file mode 100644
index 0000000000000..f27c737277d9b
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.incr/pre.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// move_iterator& operator++();
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::move_iterator<It> r(i);
+ std::move_iterator<It>& rr = ++r;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ char s[] = "123";
+ test(input_iterator<char*>(s), input_iterator<char*>(s+1));
+ test(forward_iterator<char*>(s), forward_iterator<char*>(s+1));
+ test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1));
+ test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1));
+ test(s, s+1);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp
new file mode 100644
index 0000000000000..8d507b822cd2b
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.index/difference_type.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// requires RandomAccessIterator<Iter>
+// unspecified operator[](difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n,
+ typename std::iterator_traits<It>::value_type x)
+{
+ typedef typename std::iterator_traits<It>::value_type value_type;
+ const std::move_iterator<It> r(i);
+ value_type rr = r[n];
+ assert(rr == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct do_nothing
+{
+ void operator()(void*) const {}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ char s[] = "1234567890";
+ test(random_access_iterator<char*>(s+5), 4, '0');
+ test(s+5, 4, '0');
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ int i[5];
+ typedef std::unique_ptr<int, do_nothing> Ptr;
+ Ptr p[5];
+ for (unsigned j = 0; j < 5; ++j)
+ p[j].reset(i+j);
+ test(p, 3, Ptr(i+3));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp
new file mode 100644
index 0000000000000..b0c00e3fbf864
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.ref/op_arrow.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// pointer operator->() const;
+
+#include <iterator>
+#include <cassert>
+
+template <class It>
+void
+test(It i)
+{
+ std::move_iterator<It> r(i);
+ assert(r.operator->() == i);
+}
+
+int main()
+{
+ char s[] = "123";
+ test(s);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp
new file mode 100644
index 0000000000000..6de708baa3270
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// reference operator*() const;
+
+#include <iterator>
+#include <cassert>
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#include <memory>
+#endif
+
+class A
+{
+ int data_;
+public:
+ A() : data_(1) {}
+ ~A() {data_ = -1;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.data_ == y.data_;}
+};
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::value_type x)
+{
+ std::move_iterator<It> r(i);
+ assert(*r == x);
+ typename std::iterator_traits<It>::value_type x2 = *r;
+ assert(x2 == x);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+struct do_nothing
+{
+ void operator()(void*) const {}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+ A a;
+ test(&a, A());
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ int i;
+ std::unique_ptr<int, do_nothing> p(&i);
+ test(&p, std::unique_ptr<int, do_nothing>(&i));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp
new file mode 100644
index 0000000000000..089cc29b2e940
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U>
+// requires HasAssign<Iter, const U&>
+// move_iterator&
+// operator=(const move_iterator<U>& u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+ const std::move_iterator<U> r2(u);
+ std::move_iterator<It> r1;
+ r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+ derived d;
+ test<base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp
new file mode 100644
index 0000000000000..449f7e809db4d
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op=/move_iterator.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// template <class U>
+// requires HasAssign<Iter, const U&>
+// move_iterator&
+// operator=(const move_iterator<U>& u);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+ const std::move_iterator<U> r2(u);
+ std::move_iterator<It> r1;
+ std::move_iterator<It>& rr = r1 = r2;
+ assert(r1.base() == u);
+ assert(&rr == &r1);
+}
+
+struct Base {};
+struct Derived : Base {};
+
+int main()
+{
+ Derived d;
+
+ test<input_iterator<Base*> >(input_iterator<Derived*>(&d));
+ test<forward_iterator<Base*> >(forward_iterator<Derived*>(&d));
+ test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
+ test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
+ test<Base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iter.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
new file mode 100644
index 0000000000000..9bdf7215e9ee9
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// move_iterator
+
+// Test nested types:
+
+// template <InputIterator Iter>
+// class move_iterator {
+// public:
+// typedef Iter iterator_type;
+// typedef Iter::difference_type difference_type;
+// typedef Iterator pointer;
+// typedef Iter::value_type value_type;
+// typedef value_type&& reference;
+// };
+
+#include <iterator>
+#include <type_traits>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test()
+{
+ typedef std::move_iterator<It> R;
+ typedef std::iterator_traits<It> T;
+ static_assert((std::is_same<typename R::iterator_type, It>::value), "");
+ static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
+ static_assert((std::is_same<typename R::pointer, typename T::pointer>::value), "");
+ static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ static_assert((std::is_same<typename R::reference, typename R::value_type&&>::value), "");
+#else
+ static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
+#endif
+ static_assert((std::is_same<typename R::iterator_category, typename T::iterator_category>::value), "");
+}
+
+int main()
+{
+ test<input_iterator<char*> >();
+ test<forward_iterator<char*> >();
+ test<bidirectional_iterator<char*> >();
+ test<random_access_iterator<char*> >();
+ test<char*>();
+}
diff --git a/test/std/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/move.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp
new file mode 100644
index 0000000000000..72a767d17114f
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/default.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator();
+
+#include <iterator>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test()
+{
+ std::reverse_iterator<It> r;
+}
+
+int main()
+{
+ test<bidirectional_iterator<const char*> >();
+ test<random_access_iterator<char*> >();
+ test<char*>();
+ test<const char*>();
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp
new file mode 100644
index 0000000000000..3f42f06ee08c8
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.fail.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// explicit reverse_iterator(Iter x);
+
+// test explicit
+
+#include <iterator>
+
+template <class It>
+void
+test(It i)
+{
+ std::reverse_iterator<It> r = i;
+}
+
+int main()
+{
+ const char s[] = "123";
+ test(s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp
new file mode 100644
index 0000000000000..ea213c0dcf0d1
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/iter.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// explicit reverse_iterator(Iter x);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i)
+{
+ std::reverse_iterator<It> r(i);
+ assert(r.base() == i);
+}
+
+int main()
+{
+ const char s[] = "123";
+ test(bidirectional_iterator<const char*>(s));
+ test(random_access_iterator<const char*>(s));
+ test(s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp
new file mode 100644
index 0000000000000..c0a9afecbd338
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.fail.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U>
+// requires HasConstructor<Iter, const U&>
+// reverse_iterator(const reverse_iterator<U> &u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+ std::reverse_iterator<U> r2(u);
+ std::reverse_iterator<It> r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+ derived d;
+
+ test<base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp
new file mode 100644
index 0000000000000..280e7d59ae868
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.cons/reverse_iterator.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U>
+// requires HasConstructor<Iter, const U&>
+// reverse_iterator(const reverse_iterator<U> &u);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+ const std::reverse_iterator<U> r2(u);
+ std::reverse_iterator<It> r1 = r2;
+ assert(r1.base() == u);
+}
+
+struct Base {};
+struct Derived : Base {};
+
+int main()
+{
+ Derived d;
+
+ test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
+ test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
+ test<Base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.conv/tested_elsewhere.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.make/make_reverse_iterator.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.make/make_reverse_iterator.pass.cpp
new file mode 100644
index 0000000000000..98b7331cd3869
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.make/make_reverse_iterator.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class Iterator> reverse_iterator<Iterator>
+// make_reverse_iterator(Iterator i);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+#if _LIBCPP_STD_VER > 11
+
+template <class It>
+void
+test(It i)
+{
+ const std::reverse_iterator<It> r = std::make_reverse_iterator(i);
+ assert(r.base() == i);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ random_access_iterator<const char*>b(s);
+ random_access_iterator<const char*>e(s+10);
+ while ( b != e )
+ test ( b++ );
+}
+#else
+int main () {}
+#endif
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op!=/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op!=/test.pass.cpp
new file mode 100644
index 0000000000000..29da57e3b5af6
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op!=/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <BidirectionalIterator Iter1, BidirectionalIterator Iter2>
+// requires HasEqualTo<Iter1, Iter2>
+// bool
+// operator!=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::reverse_iterator<It> r1(l);
+ const std::reverse_iterator<It> r2(r);
+ assert((r1 != r2) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s), false);
+ test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1), true);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
+ test(s, s, false);
+ test(s, s+1, true);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp
new file mode 100644
index 0000000000000..bd936060c4d45
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/post.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator operator++(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It> rr = r++;
+ assert(r.base() == x);
+ assert(rr.base() == i);
+}
+
+int main()
+{
+ const char* s = "123";
+ test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
+ test(s+1, s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp
new file mode 100644
index 0000000000000..f68a612fae6b2
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op++/pre.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator& operator++();
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It>& rr = ++r;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ const char* s = "123";
+ test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s));
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s));
+ test(s+1, s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp
new file mode 100644
index 0000000000000..39129d6b64d89
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+/difference_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+// reverse_iterator operator+(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ const std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It> rr = r + n;
+ assert(rr.base() == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+ test(s+5, 5, s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp
new file mode 100644
index 0000000000000..ac97aaf8c2031
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op+=/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+// reverse_iterator& operator+=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It>& rr = r += n;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+ test(s+5, 5, s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp
new file mode 100644
index 0000000000000..c3126e8c21ff6
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/post.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator operator--(int);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It> rr = r--;
+ assert(r.base() == x);
+ assert(rr.base() == i);
+}
+
+int main()
+{
+ const char* s = "123";
+ test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s+2));
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s+2));
+ test(s+1, s+2);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp
new file mode 100644
index 0000000000000..f9361cf9c72c0
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op--/pre.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reverse_iterator& operator--();
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, It x)
+{
+ std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It>& rr = --r;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ const char* s = "123";
+ test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s+2));
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s+2));
+ test(s+1, s+2);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp
new file mode 100644
index 0000000000000..79d477976fb75
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-/difference_type.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+// reverse_iterator operator-(difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ const std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It> rr = r - n;
+ assert(rr.base() == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+ test(s+5, 5, s+10);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp
new file mode 100644
index 0000000000000..93addf99dc61a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op-=/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+// reverse_iterator& operator-=(difference_type n);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It>& rr = r -= n;
+ assert(r.base() == x);
+ assert(&rr == &r);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
+ test(s+5, 5, s+10);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp
new file mode 100644
index 0000000000000..7a7759843eea1
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op.star/op_star.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// reference operator*() const;
+
+// Be sure to respect LWG 198:
+// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198
+// LWG 198 was superseded by LWG 2360
+// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2360
+
+#include <iterator>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ A() : data_(1) {}
+ ~A() {data_ = -1;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.data_ == y.data_;}
+};
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::value_type x)
+{
+ std::reverse_iterator<It> r(i);
+ assert(*r == x);
+}
+
+int main()
+{
+ A a;
+ test(&a+1, A());
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp
new file mode 100644
index 0000000000000..18f97801251dd
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U>
+// requires HasAssign<Iter, const U&>
+// reverse_iterator&
+// operator=(const reverse_iterator<U>& u);
+
+// test requires
+
+#include <iterator>
+
+template <class It, class U>
+void
+test(U u)
+{
+ const std::reverse_iterator<U> r2(u);
+ std::reverse_iterator<It> r1;
+ r1 = r2;
+}
+
+struct base {};
+struct derived {};
+
+int main()
+{
+ derived d;
+ test<base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp
new file mode 100644
index 0000000000000..92573f9a92420
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op=/reverse_iterator.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <class U>
+// requires HasAssign<Iter, const U&>
+// reverse_iterator&
+// operator=(const reverse_iterator<U>& u);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It, class U>
+void
+test(U u)
+{
+ const std::reverse_iterator<U> r2(u);
+ std::reverse_iterator<It> r1;
+ std::reverse_iterator<It>& rr = r1 = r2;
+ assert(r1.base() == u);
+ assert(&rr == &r1);
+}
+
+struct Base {};
+struct Derived : Base {};
+
+int main()
+{
+ Derived d;
+
+ test<bidirectional_iterator<Base*> >(bidirectional_iterator<Derived*>(&d));
+ test<random_access_iterator<const Base*> >(random_access_iterator<Derived*>(&d));
+ test<Base*>(&d);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp
new file mode 100644
index 0000000000000..3da4b951df1e7
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.op==/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <BidirectionalIterator Iter1, BidirectionalIterator Iter2>
+// requires HasEqualTo<Iter1, Iter2>
+// bool
+// operator==(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::reverse_iterator<It> r1(l);
+ const std::reverse_iterator<It> r2(r);
+ assert((r1 == r2) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s), true);
+ test(bidirectional_iterator<const char*>(s), bidirectional_iterator<const char*>(s+1), false);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
+ test(s, s, true);
+ test(s, s+1, false);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp
new file mode 100644
index 0000000000000..437bb6f9f7efc
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opdiff/test.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasMinus<Iter2, Iter1>
+// auto operator-(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y)
+// -> decltype(y.base() - x.base());
+
+#include <iterator>
+#include <cstddef>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It1, class It2>
+void
+test(It1 l, It2 r, std::ptrdiff_t x)
+{
+ const std::reverse_iterator<It1> r1(l);
+ const std::reverse_iterator<It2> r2(r);
+ assert((r1 - r2) == x);
+}
+
+int main()
+{
+ char s[3] = {0};
+ test(random_access_iterator<const char*>(s), random_access_iterator<char*>(s), 0);
+ test(random_access_iterator<char*>(s), random_access_iterator<const char*>(s+1), 1);
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<char*>(s), -1);
+ test(s, s, 0);
+ test(s, s+1, 1);
+ test(s+1, s, -1);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp
new file mode 100644
index 0000000000000..afbb334ebfd5b
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasGreater<Iter1, Iter2>
+// bool
+// operator>(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::reverse_iterator<It> r1(l);
+ const std::reverse_iterator<It> r2(r);
+ assert((r1 > r2) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), false);
+ test(s, s, false);
+ test(s, s+1, true);
+ test(s+1, s, false);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp
new file mode 100644
index 0000000000000..c6e79aff126fc
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opgt=/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasGreater<Iter1, Iter2>
+// bool
+// operator>=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::reverse_iterator<It> r1(l);
+ const std::reverse_iterator<It> r2(r);
+ assert((r1 >= r2) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), true);
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), false);
+ test(s, s, true);
+ test(s, s+1, true);
+ test(s+1, s, false);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp
new file mode 100644
index 0000000000000..16f4a072855a4
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opindex/difference_type.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// requires RandomAccessIterator<Iter>
+// unspecified operator[](difference_type n) const;
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n,
+ typename std::iterator_traits<It>::value_type x)
+{
+ typedef typename std::iterator_traits<It>::value_type value_type;
+ const std::reverse_iterator<It> r(i);
+ value_type rr = r[n];
+ assert(rr == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 4, '1');
+ test(s+5, 4, '1');
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp
new file mode 100644
index 0000000000000..2b389b853a5a1
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasGreater<Iter1, Iter2>
+// bool
+// operator<(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::reverse_iterator<It> r1(l);
+ const std::reverse_iterator<It> r2(r);
+ assert((r1 < r2) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), false);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true);
+ test(s, s, false);
+ test(s, s+1, false);
+ test(s+1, s, true);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp
new file mode 100644
index 0000000000000..6c4f05cdf6565
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.oplt=/test.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
+// requires HasGreater<Iter1, Iter2>
+// bool
+// operator<=(const reverse_iterator<Iter1>& x, const reverse_iterator<Iter2>& y);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It l, It r, bool x)
+{
+ const std::reverse_iterator<It> r1(l);
+ const std::reverse_iterator<It> r2(r);
+ assert((r1 <= r2) == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s), true);
+ test(random_access_iterator<const char*>(s), random_access_iterator<const char*>(s+1), false);
+ test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s), true);
+ test(s, s, true);
+ test(s, s+1, false);
+ test(s+1, s, true);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp
new file mode 100644
index 0000000000000..efbdf1406c96f
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opref/op_arrow.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// pointer operator->() const;
+
+// Be sure to respect LWG 198:
+// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#198
+// LWG 198 was superseded by LWG 2360
+// http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2360
+
+
+#include <iterator>
+#include <list>
+#include <cassert>
+
+class A
+{
+ int data_;
+public:
+ A() : data_(1) {}
+ ~A() {data_ = -1;}
+
+ int get() const {return data_;}
+
+ friend bool operator==(const A& x, const A& y)
+ {return x.data_ == y.data_;}
+};
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::value_type x)
+{
+ std::reverse_iterator<It> r(i);
+ assert(r->get() == x.get());
+}
+
+class B
+{
+ int data_;
+public:
+ B(int d=1) : data_(d) {}
+ ~B() {data_ = -1;}
+
+ int get() const {return data_;}
+
+ friend bool operator==(const B& x, const B& y)
+ {return x.data_ == y.data_;}
+ const B *operator&() const { return nullptr; }
+ B *operator&() { return nullptr; }
+};
+
+int main()
+{
+ A a;
+ test(&a+1, A());
+
+ {
+ std::list<B> l;
+ l.push_back(B(0));
+ l.push_back(B(1));
+ l.push_back(B(2));
+
+ {
+ std::list<B>::const_iterator i = l.begin();
+ assert ( i->get() == 0 ); ++i;
+ assert ( i->get() == 1 ); ++i;
+ assert ( i->get() == 2 ); ++i;
+ assert ( i == l.end ());
+ }
+
+ {
+ std::list<B>::const_reverse_iterator ri = l.rbegin();
+ assert ( ri->get() == 2 ); ++ri;
+ assert ( ri->get() == 1 ); ++ri;
+ assert ( ri->get() == 0 ); ++ri;
+ assert ( ri == l.rend ());
+ }
+ }
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp
new file mode 100644
index 0000000000000..74747cb1f0f78
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.ops/reverse.iter.opsum/difference_type.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// template <RandomAccessIterator Iterator>
+// reverse_iterator<Iter>
+// operator+(Iter::difference_type n, const reverse_iterator<Iter>& x);
+
+#include <iterator>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class It>
+void
+test(It i, typename std::iterator_traits<It>::difference_type n, It x)
+{
+ const std::reverse_iterator<It> r(i);
+ std::reverse_iterator<It> rr = n + r;
+ assert(rr.base() == x);
+}
+
+int main()
+{
+ const char* s = "1234567890";
+ test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s));
+ test(s+5, 5, s);
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp
new file mode 100644
index 0000000000000..292a777876fb2
--- /dev/null
+++ b/test/std/iterators/predef.iterators/reverse.iterators/reverse.iterator/types.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// reverse_iterator
+
+// Test nested types and data member:
+
+// template <BidirectionalIterator Iter>
+// class reverse_iterator {
+// protected:
+// Iter current;
+// public:
+// iterator<typename iterator_traits<Iterator>::iterator_category,
+// typename iterator_traits<Iterator>::value_type,
+// typename iterator_traits<Iterator>::difference_type,
+// typename iterator_traits<Iterator>::pointer,
+// typename iterator_traits<Iterator>::reference> {
+// };
+
+#include <iterator>
+#include <type_traits>
+
+#include "test_iterators.h"
+
+template <class It>
+struct find_current
+ : private std::reverse_iterator<It>
+{
+ void test() {++(this->current);}
+};
+
+template <class It>
+void
+test()
+{
+ typedef std::reverse_iterator<It> R;
+ typedef std::iterator_traits<It> T;
+ find_current<It> q;
+ q.test();
+ static_assert((std::is_same<typename R::iterator_type, It>::value), "");
+ static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
+ static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
+ static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
+ static_assert((std::is_same<typename R::pointer, typename std::iterator_traits<It>::pointer>::value), "");
+ static_assert((std::is_same<typename R::iterator_category, typename T::iterator_category>::value), "");
+}
+
+int main()
+{
+ test<bidirectional_iterator<char*> >();
+ test<random_access_iterator<char*> >();
+ test<char*>();
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
new file mode 100644
index 0000000000000..0d70c7fc9ed3f
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/copy.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator(const istream_iterator& x);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istream_iterator<int> io;
+ std::istream_iterator<int> i = io;
+ assert(i == std::istream_iterator<int>());
+ }
+ {
+ std::istringstream inf(" 1 23");
+ std::istream_iterator<int> io(inf);
+ std::istream_iterator<int> i = io;
+ assert(i != std::istream_iterator<int>());
+ int j = 0;
+ j = *i;
+ assert(j == 1);
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.fail.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.fail.cpp
new file mode 100644
index 0000000000000..5e6cc5455998c
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// constexpr istream_iterator();
+
+#include <iterator>
+#include <cassert>
+
+struct S { S(); }; // not constexpr
+
+int main()
+{
+#if __cplusplus >= 201103L
+ {
+ constexpr std::istream_iterator<S> it;
+ }
+#else
+#error "C++11 only test"
+#endif
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
new file mode 100644
index 0000000000000..bea07ec2272e5
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/default.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// constexpr istream_iterator();
+
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::istream_iterator<int> T;
+ T it;
+ assert(it == T());
+#if __cplusplus >= 201103L
+ constexpr T it2;
+#endif
+ }
+
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp
new file mode 100644
index 0000000000000..12a6f90e88967
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.cons/istream.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator(istream_type& s);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::istringstream inf(" 1 23");
+ std::istream_iterator<int> i(inf);
+ assert(i != std::istream_iterator<int>());
+ assert(inf.peek() == ' ');
+ assert(inf.good());
+ int j = 0;
+ inf >> j;
+ assert(j == 23);
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp
new file mode 100644
index 0000000000000..5c4ddcad32eaf
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/arrow.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// const T* operator->() const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+struct A
+{
+ double d_;
+ int i_;
+};
+
+std::istream& operator>>(std::istream& is, A& a)
+{
+ return is >> a.d_ >> a.i_;
+}
+
+int main()
+{
+ std::istringstream inf("1.5 23 ");
+ std::istream_iterator<A> i(inf);
+ assert(i->d_ == 1.5);
+ assert(i->i_ == 23);
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp
new file mode 100644
index 0000000000000..e6f86d483369d
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/dereference.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// const T& operator*() const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::istringstream inf(" 1 23");
+ std::istream_iterator<int> i(inf);
+ int j = 0;
+ j = *i;
+ assert(j == 1);
+ j = *i;
+ assert(j == 1);
+ ++i;
+ j = *i;
+ assert(j == 23);
+ j = *i;
+ assert(j == 23);
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
new file mode 100644
index 0000000000000..0bee916d50c93
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// template <class T, class charT, class traits, class Distance>
+// bool operator==(const istream_iterator<T,charT,traits,Distance> &x,
+// const istream_iterator<T,charT,traits,Distance> &y);
+//
+// template <class T, class charT, class traits, class Distance>
+// bool operator!=(const istream_iterator<T,charT,traits,Distance> &x,
+// const istream_iterator<T,charT,traits,Distance> &y);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::istringstream inf1(" 1 23");
+ std::istringstream inf2(" 1 23");
+ std::istream_iterator<int> i1(inf1);
+ std::istream_iterator<int> i2(inf1);
+ std::istream_iterator<int> i3(inf2);
+ std::istream_iterator<int> i4;
+ std::istream_iterator<int> i5;
+ assert(i1 == i1);
+ assert(i1 == i2);
+ assert(i1 != i3);
+ assert(i1 != i4);
+ assert(i1 != i5);
+
+ assert(i2 == i2);
+ assert(i2 != i3);
+ assert(i2 != i4);
+ assert(i2 != i5);
+
+ assert(i3 == i3);
+ assert(i3 != i4);
+ assert(i3 != i5);
+
+ assert(i4 == i4);
+ assert(i4 == i5);
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp
new file mode 100644
index 0000000000000..f5c49e379184a
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/post_increment.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::istringstream inf(" 1 23");
+ std::istream_iterator<int> i(inf);
+ std::istream_iterator<int> icopy = i++;
+ assert(icopy == i);
+ int j = 0;
+ j = *i;
+ assert(j == 23);
+ j = 0;
+ j = *icopy;
+ assert(j == 1);
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp
new file mode 100644
index 0000000000000..87173f7dc1829
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/pre_increment.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class istream_iterator
+
+// istream_iterator& operator++();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::istringstream inf(" 1 23");
+ std::istream_iterator<int> i(inf);
+ std::istream_iterator<int>& iref = ++i;
+ assert(&iref == &i);
+ int j = 0;
+ j = *i;
+ assert(j == 23);
+}
diff --git a/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp b/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
new file mode 100644
index 0000000000000..85a70a017976b
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, class charT = char, class traits = char_traits<charT>,
+// class Distance = ptrdiff_t>
+// class istream_iterator
+// : public iterator<input_iterator_tag, T, Distance, const T*, const T&>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef basic_istream<charT,traits> istream_type;
+// ...
+//
+// If T is a literal type, then the default constructor shall be a constexpr constructor.
+// If T is a literal type, then this constructor shall be a trivial copy constructor.
+// If T is a literal type, then this destructor shall be a trivial destructor.
+
+#include <iterator>
+#include <type_traits>
+#include <string>
+
+int main()
+{
+ typedef std::istream_iterator<double> I1;
+ static_assert((std::is_convertible<I1,
+ std::iterator<std::input_iterator_tag, double, std::ptrdiff_t,
+ const double*, const double&> >::value), "");
+ static_assert((std::is_same<I1::char_type, char>::value), "");
+ static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
+ static_assert( std::is_trivially_copy_constructible<I1>::value, "");
+ static_assert( std::is_trivially_destructible<I1>::value, "");
+
+ typedef std::istream_iterator<unsigned, wchar_t> I2;
+ static_assert((std::is_convertible<I2,
+ std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t,
+ const unsigned*, const unsigned&> >::value), "");
+ static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+ static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
+ static_assert( std::is_trivially_copy_constructible<I2>::value, "");
+ static_assert( std::is_trivially_destructible<I2>::value, "");
+
+ typedef std::istream_iterator<std::string> I3;
+ static_assert(!std::is_trivially_copy_constructible<I3>::value, "");
+ static_assert(!std::is_trivially_destructible<I3>::value, "");
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp
new file mode 100644
index 0000000000000..46ac390d931f1
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/default.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+//
+// istreambuf_iterator() throw();
+//
+// All specializations of istreambuf_iterator shall have a trivial copy constructor,
+// a constexpr default constructor and a trivial destructor.
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::istreambuf_iterator<char> T;
+ T it;
+ assert(it == T());
+#if __cplusplus >= 201103L
+ constexpr T it2;
+#endif
+ }
+ {
+ typedef std::istreambuf_iterator<wchar_t> T;
+ T it;
+ assert(it == T());
+#if __cplusplus >= 201103L
+ constexpr T it2;
+#endif
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp
new file mode 100644
index 0000000000000..69e98265e2fe5
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/istream.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator(basic_istream<charT,traits>& s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf;
+ std::istreambuf_iterator<char> i(inf);
+ assert(i == std::istreambuf_iterator<char>());
+ }
+ {
+ std::istringstream inf("a");
+ std::istreambuf_iterator<char> i(inf);
+ assert(i != std::istreambuf_iterator<char>());
+ }
+ {
+ std::wistringstream inf;
+ std::istreambuf_iterator<wchar_t> i(inf);
+ assert(i == std::istreambuf_iterator<wchar_t>());
+ }
+ {
+ std::wistringstream inf(L"a");
+ std::istreambuf_iterator<wchar_t> i(inf);
+ assert(i != std::istreambuf_iterator<wchar_t>());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp
new file mode 100644
index 0000000000000..f5a5fa0c643cd
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/proxy.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator(const proxy& p) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf("abc");
+ std::istreambuf_iterator<char> j(inf);
+ std::istreambuf_iterator<char> i = j++;
+ assert(i != std::istreambuf_iterator<char>());
+ assert(*i == 'b');
+ }
+ {
+ std::wistringstream inf(L"abc");
+ std::istreambuf_iterator<wchar_t> j(inf);
+ std::istreambuf_iterator<wchar_t> i = j++;
+ assert(i != std::istreambuf_iterator<wchar_t>());
+ assert(*i == L'b');
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp
new file mode 100644
index 0000000000000..020b4f24bce50
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator.cons/streambuf.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator(basic_streambuf<charT,traits>* s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istreambuf_iterator<char> i(nullptr);
+ assert(i == std::istreambuf_iterator<char>());
+ }
+ {
+ std::istringstream inf;
+ std::istreambuf_iterator<char> i(inf.rdbuf());
+ assert(i == std::istreambuf_iterator<char>());
+ }
+ {
+ std::istringstream inf("a");
+ std::istreambuf_iterator<char> i(inf.rdbuf());
+ assert(i != std::istreambuf_iterator<char>());
+ }
+ {
+ std::istreambuf_iterator<wchar_t> i(nullptr);
+ assert(i == std::istreambuf_iterator<wchar_t>());
+ }
+ {
+ std::wistringstream inf;
+ std::istreambuf_iterator<wchar_t> i(inf.rdbuf());
+ assert(i == std::istreambuf_iterator<wchar_t>());
+ }
+ {
+ std::wistringstream inf(L"a");
+ std::istreambuf_iterator<wchar_t> i(inf.rdbuf());
+ assert(i != std::istreambuf_iterator<wchar_t>());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp
new file mode 100644
index 0000000000000..2005d303fb3b7
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_equal/equal.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// bool equal(istreambuf_iterator<charT,traits>& b) const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf1("abc");
+ std::istringstream inf2("def");
+ std::istreambuf_iterator<char> i1(inf1);
+ std::istreambuf_iterator<char> i2(inf2);
+ std::istreambuf_iterator<char> i3;
+ std::istreambuf_iterator<char> i4;
+
+ assert( i1.equal(i1));
+ assert( i1.equal(i2));
+ assert(!i1.equal(i3));
+ assert(!i1.equal(i4));
+
+ assert( i2.equal(i1));
+ assert( i2.equal(i2));
+ assert(!i2.equal(i3));
+ assert(!i2.equal(i4));
+
+ assert(!i3.equal(i1));
+ assert(!i3.equal(i2));
+ assert( i3.equal(i3));
+ assert( i3.equal(i4));
+
+ assert(!i4.equal(i1));
+ assert(!i4.equal(i2));
+ assert( i4.equal(i3));
+ assert( i4.equal(i4));
+ }
+ {
+ std::wistringstream inf1(L"abc");
+ std::wistringstream inf2(L"def");
+ std::istreambuf_iterator<wchar_t> i1(inf1);
+ std::istreambuf_iterator<wchar_t> i2(inf2);
+ std::istreambuf_iterator<wchar_t> i3;
+ std::istreambuf_iterator<wchar_t> i4;
+
+ assert( i1.equal(i1));
+ assert( i1.equal(i2));
+ assert(!i1.equal(i3));
+ assert(!i1.equal(i4));
+
+ assert( i2.equal(i1));
+ assert( i2.equal(i2));
+ assert(!i2.equal(i3));
+ assert(!i2.equal(i4));
+
+ assert(!i3.equal(i1));
+ assert(!i3.equal(i2));
+ assert( i3.equal(i3));
+ assert( i3.equal(i4));
+
+ assert(!i4.equal(i1));
+ assert(!i4.equal(i2));
+ assert( i4.equal(i3));
+ assert( i4.equal(i4));
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.cpp
new file mode 100644
index 0000000000000..5e8536423d8bd
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op!=/not_equal.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// template <class charT, class traits>
+// bool operator!=(const istreambuf_iterator<charT,traits>& a,
+// const istreambuf_iterator<charT,traits>& b);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf1("abc");
+ std::istringstream inf2("def");
+ std::istreambuf_iterator<char> i1(inf1);
+ std::istreambuf_iterator<char> i2(inf2);
+ std::istreambuf_iterator<char> i3;
+ std::istreambuf_iterator<char> i4;
+
+ assert(!(i1 != i1));
+ assert(!(i1 != i2));
+ assert( (i1 != i3));
+ assert( (i1 != i4));
+
+ assert(!(i2 != i1));
+ assert(!(i2 != i2));
+ assert( (i2 != i3));
+ assert( (i2 != i4));
+
+ assert( (i3 != i1));
+ assert( (i3 != i2));
+ assert(!(i3 != i3));
+ assert(!(i3 != i4));
+
+ assert( (i4 != i1));
+ assert( (i4 != i2));
+ assert(!(i4 != i3));
+ assert(!(i4 != i4));
+ }
+ {
+ std::wistringstream inf1(L"abc");
+ std::wistringstream inf2(L"def");
+ std::istreambuf_iterator<wchar_t> i1(inf1);
+ std::istreambuf_iterator<wchar_t> i2(inf2);
+ std::istreambuf_iterator<wchar_t> i3;
+ std::istreambuf_iterator<wchar_t> i4;
+
+ assert(!(i1 != i1));
+ assert(!(i1 != i2));
+ assert( (i1 != i3));
+ assert( (i1 != i4));
+
+ assert(!(i2 != i1));
+ assert(!(i2 != i2));
+ assert( (i2 != i3));
+ assert( (i2 != i4));
+
+ assert( (i3 != i1));
+ assert( (i3 != i2));
+ assert(!(i3 != i3));
+ assert(!(i3 != i4));
+
+ assert( (i4 != i1));
+ assert( (i4 != i2));
+ assert(!(i4 != i3));
+ assert(!(i4 != i4));
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp
new file mode 100644
index 0000000000000..19fb02fc46c68
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op++/dereference.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// charT operator*() const
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf("abc");
+ std::istreambuf_iterator<char> i(inf);
+ assert(*i == 'a');
+ ++i;
+ assert(*i == 'b');
+ ++i;
+ assert(*i == 'c');
+ }
+ {
+ std::wistringstream inf(L"abc");
+ std::istreambuf_iterator<wchar_t> i(inf);
+ assert(*i == L'a');
+ ++i;
+ assert(*i == L'b');
+ ++i;
+ assert(*i == L'c');
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp
new file mode 100644
index 0000000000000..919576920ef5b
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op==/equal.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// template <class charT, class traits>
+// bool operator==(const istreambuf_iterator<charT,traits>& a,
+// const istreambuf_iterator<charT,traits>& b);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf1("abc");
+ std::istringstream inf2("def");
+ std::istreambuf_iterator<char> i1(inf1);
+ std::istreambuf_iterator<char> i2(inf2);
+ std::istreambuf_iterator<char> i3;
+ std::istreambuf_iterator<char> i4;
+
+ assert( (i1 == i1));
+ assert( (i1 == i2));
+ assert(!(i1 == i3));
+ assert(!(i1 == i4));
+
+ assert( (i2 == i1));
+ assert( (i2 == i2));
+ assert(!(i2 == i3));
+ assert(!(i2 == i4));
+
+ assert(!(i3 == i1));
+ assert(!(i3 == i2));
+ assert( (i3 == i3));
+ assert( (i3 == i4));
+
+ assert(!(i4 == i1));
+ assert(!(i4 == i2));
+ assert( (i4 == i3));
+ assert( (i4 == i4));
+ }
+ {
+ std::wistringstream inf1(L"abc");
+ std::wistringstream inf2(L"def");
+ std::istreambuf_iterator<wchar_t> i1(inf1);
+ std::istreambuf_iterator<wchar_t> i2(inf2);
+ std::istreambuf_iterator<wchar_t> i3;
+ std::istreambuf_iterator<wchar_t> i4;
+
+ assert( (i1 == i1));
+ assert( (i1 == i2));
+ assert(!(i1 == i3));
+ assert(!(i1 == i4));
+
+ assert( (i2 == i1));
+ assert( (i2 == i2));
+ assert(!(i2 == i3));
+ assert(!(i2 == i4));
+
+ assert(!(i3 == i1));
+ assert(!(i3 == i2));
+ assert( (i3 == i3));
+ assert( (i3 == i4));
+
+ assert(!(i4 == i1));
+ assert(!(i4 == i2));
+ assert( (i4 == i3));
+ assert( (i4 == i4));
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp
new file mode 100644
index 0000000000000..e3bf5e2bd84f8
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/arrow.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// pointer operator->() const;
+
+#include <iostream>
+#include <sstream>
+#include <streambuf>
+
+typedef char C;
+int main ()
+{
+ std::istringstream s("filename");
+ std::istreambuf_iterator<char> i(s);
+
+ (*i).~C(); // This is well-formed...
+ i->~C(); // ... so this should be supported!
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp
new file mode 100644
index 0000000000000..2e4f52ce71bca
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/post_increment.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// proxy istreambuf_iterator<charT,traits>::operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf("abc");
+ std::istreambuf_iterator<char> i(inf);
+ assert(*i++ == 'a');
+ assert(*i++ == 'b');
+ assert(*i++ == 'c');
+ assert(i == std::istreambuf_iterator<char>());
+ }
+ {
+ std::wistringstream inf(L"abc");
+ std::istreambuf_iterator<wchar_t> i(inf);
+ assert(*i++ == L'a');
+ assert(*i++ == L'b');
+ assert(*i++ == L'c');
+ assert(i == std::istreambuf_iterator<wchar_t>());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp
new file mode 100644
index 0000000000000..cb7960a0e4eca
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_op_astrk/pre_increment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// istreambuf_iterator
+
+// istreambuf_iterator<charT,traits>&
+// istreambuf_iterator<charT,traits>::operator++();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf("abc");
+ std::istreambuf_iterator<char> i(inf);
+ assert(*i == 'a');
+ assert(*++i == 'b');
+ assert(*++i == 'c');
+ assert(++i == std::istreambuf_iterator<char>());
+ }
+ {
+ std::wistringstream inf(L"abc");
+ std::istreambuf_iterator<wchar_t> i(inf);
+ assert(*i == L'a');
+ assert(*++i == L'b');
+ assert(*++i == L'c');
+ assert(++i == std::istreambuf_iterator<wchar_t>());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.pass.cpp
new file mode 100644
index 0000000000000..acaf2f569b1fb
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/istreambuf.iterator_proxy/proxy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class charT, class traits = char_traits<charT> >
+// class istreambuf_iterator
+// : public iterator<input_iterator_tag, charT,
+// typename traits::off_type, charT*,
+// charT>
+// {
+// public:
+// ...
+// proxy operator++(int);
+
+// class proxy
+// {
+// public:
+// charT operator*();
+// };
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::istringstream inf("abc");
+ std::istreambuf_iterator<char> i(inf);
+ assert(*i++ == 'a');
+ }
+ {
+ std::wistringstream inf(L"abc");
+ std::istreambuf_iterator<wchar_t> i(inf);
+ assert(*i++ == L'a');
+ }
+}
diff --git a/test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp b/test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp
new file mode 100644
index 0000000000000..2ad927cf952c2
--- /dev/null
+++ b/test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template<class charT, class traits = char_traits<charT> >
+// class istreambuf_iterator
+// : public iterator<input_iterator_tag, charT,
+// typename traits::off_type, unspecified,
+// charT>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef typename traits::int_type int_type;
+// typedef basic_streambuf<charT,traits> streambuf_type;
+// typedef basic_istream<charT,traits> istream_type;
+// ...
+//
+// All specializations of istreambuf_iterator shall have a trivial copy constructor,
+// a constexpr default constructor and a trivial destructor.
+
+#include <iterator>
+#include <string>
+#include <type_traits>
+
+int main()
+{
+ typedef std::istreambuf_iterator<char> I1;
+ static_assert((std::is_convertible<I1,
+ std::iterator<std::input_iterator_tag, char, std::char_traits<char>::off_type,
+ char*, char> >::value), "");
+ static_assert((std::is_same<I1::char_type, char>::value), "");
+ static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<I1::int_type, I1::traits_type::int_type>::value), "");
+ static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
+ static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
+ static_assert((std::is_nothrow_default_constructible<I1>::value), "" );
+ static_assert((std::is_trivially_copy_constructible<I1>::value), "" );
+ static_assert((std::is_trivially_destructible<I1>::value), "" );
+
+ typedef std::istreambuf_iterator<wchar_t> I2;
+ static_assert((std::is_convertible<I2,
+ std::iterator<std::input_iterator_tag, wchar_t, std::char_traits<wchar_t>::off_type,
+ wchar_t*, wchar_t> >::value), "");
+ static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+ static_assert((std::is_same<I2::int_type, I2::traits_type::int_type>::value), "");
+ static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
+ static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
+ static_assert((std::is_nothrow_default_constructible<I2>::value), "" );
+ static_assert((std::is_trivially_copy_constructible<I2>::value), "" );
+ static_assert((std::is_trivially_destructible<I2>::value), "" );
+}
diff --git a/test/std/iterators/stream.iterators/iterator.range/begin_array.pass.cpp b/test/std/iterators/stream.iterators/iterator.range/begin_array.pass.cpp
new file mode 100644
index 0000000000000..42c8c3dd93da7
--- /dev/null
+++ b/test/std/iterators/stream.iterators/iterator.range/begin_array.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, size_t N> T* begin(T (&array)[N]);
+
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3};
+ int* i = std::begin(ia);
+ assert(*i == 1);
+ *i = 2;
+ assert(ia[0] == 2);
+}
diff --git a/test/std/iterators/stream.iterators/iterator.range/begin_const.pass.cpp b/test/std/iterators/stream.iterators/iterator.range/begin_const.pass.cpp
new file mode 100644
index 0000000000000..7dca8b071e10f
--- /dev/null
+++ b/test/std/iterators/stream.iterators/iterator.range/begin_const.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto begin(const C& c) -> decltype(c.begin());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3};
+ const std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+ std::vector<int>::const_iterator i = begin(v);
+ assert(*i == 1);
+}
diff --git a/test/std/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp b/test/std/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp
new file mode 100644
index 0000000000000..de4c8b0f24716
--- /dev/null
+++ b/test/std/iterators/stream.iterators/iterator.range/begin_non_const.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto begin(C& c) -> decltype(c.begin());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3};
+ std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+ std::vector<int>::iterator i = begin(v);
+ assert(*i == 1);
+ *i = 2;
+ assert(*i == 2);
+}
diff --git a/test/std/iterators/stream.iterators/iterator.range/end_array.pass.cpp b/test/std/iterators/stream.iterators/iterator.range/end_array.pass.cpp
new file mode 100644
index 0000000000000..628e5e901e6d0
--- /dev/null
+++ b/test/std/iterators/stream.iterators/iterator.range/end_array.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, size_t N> T* end(T (&array)[N]);
+
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3};
+ int* i = std::begin(ia);
+ int* e = std::end(ia);
+ assert(e == ia + 3);
+ assert(e - i == 3);
+}
diff --git a/test/std/iterators/stream.iterators/iterator.range/end_const.pass.cpp b/test/std/iterators/stream.iterators/iterator.range/end_const.pass.cpp
new file mode 100644
index 0000000000000..7fa26171f109e
--- /dev/null
+++ b/test/std/iterators/stream.iterators/iterator.range/end_const.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto end(const C& c) -> decltype(c.end());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3};
+ const std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+ std::vector<int>::const_iterator i = end(v);
+ assert(i == v.cend());
+}
diff --git a/test/std/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp b/test/std/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp
new file mode 100644
index 0000000000000..8c75433638fc9
--- /dev/null
+++ b/test/std/iterators/stream.iterators/iterator.range/end_non_const.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class C> auto end(C& c) -> decltype(c.end());
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ int ia[] = {1, 2, 3};
+ std::vector<int> v(ia, ia + sizeof(ia)/sizeof(ia[0]));
+ std::vector<int>::iterator i = end(v);
+ assert(i == v.end());
+}
diff --git a/test/std/iterators/stream.iterators/nothing_to_do.pass.cpp b/test/std/iterators/stream.iterators/nothing_to_do.pass.cpp
new file mode 100644
index 0000000000000..b58f5c55b643a
--- /dev/null
+++ b/test/std/iterators/stream.iterators/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp
new file mode 100644
index 0000000000000..88624581df9a6
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/copy.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator(const ostream_iterator& x);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::ostringstream outf;
+ std::ostream_iterator<int> i(outf);
+ std::ostream_iterator<int> j = i;
+ assert(outf.good());
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp
new file mode 100644
index 0000000000000..321cfbdb82c8d
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator(ostream_type& s);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::ostringstream outf;
+ std::ostream_iterator<int> i(outf);
+ assert(outf.good());
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp
new file mode 100644
index 0000000000000..8e5c771a4ab40
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.cons.des/ostream_delem.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator(ostream_type& s, const charT* delimiter);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostream_iterator<int> i(outf, ", ");
+ assert(outf.good());
+ }
+ {
+ std::wostringstream outf;
+ std::ostream_iterator<double, wchar_t> i(outf, L", ");
+ assert(outf.good());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp
new file mode 100644
index 0000000000000..02ef571a06f96
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator& operator=(const T& value);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostream_iterator<int> i(outf);
+ i = 2.4;
+ assert(outf.str() == "2");
+ }
+ {
+ std::ostringstream outf;
+ std::ostream_iterator<int> i(outf, ", ");
+ i = 2.4;
+ assert(outf.str() == "2, ");
+ }
+ {
+ std::wostringstream outf;
+ std::ostream_iterator<int, wchar_t> i(outf);
+ i = 2.4;
+ assert(outf.str() == L"2");
+ }
+ {
+ std::wostringstream outf;
+ std::ostream_iterator<int, wchar_t> i(outf, L", ");
+ i = 2.4;
+ assert(outf.str() == L"2, ");
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp
new file mode 100644
index 0000000000000..322107528f4b5
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/dereference.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator& operator*() const;
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::ostringstream os;
+ std::ostream_iterator<int> i(os);
+ std::ostream_iterator<int>& iref = *i;
+ assert(&iref == &i);
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp
new file mode 100644
index 0000000000000..00b63e8da9b5f
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/increment.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostream_iterator
+
+// ostream_iterator& operator++();
+// ostream_iterator& operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ std::ostringstream os;
+ std::ostream_iterator<int> i(os);
+ std::ostream_iterator<int>& iref1 = ++i;
+ assert(&iref1 == &i);
+ std::ostream_iterator<int>& iref2 = i++;
+ assert(&iref2 == &i);
+}
diff --git a/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
new file mode 100644
index 0000000000000..460da642bc6ed
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class T, class charT = char, class traits = char_traits<charT>,
+// class Distance = ptrdiff_t>
+// class ostream_iterator
+// : public iterator<output_iterator_tag, void, void, void, void>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef basic_istream<charT,traits> istream_type;
+// ...
+
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ typedef std::ostream_iterator<double> I1;
+ static_assert((std::is_convertible<I1,
+ std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+ static_assert((std::is_same<I1::char_type, char>::value), "");
+ static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
+ typedef std::ostream_iterator<unsigned, wchar_t> I2;
+ static_assert((std::is_convertible<I2,
+ std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+ static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+ static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp
new file mode 100644
index 0000000000000..c46cf48222923
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/ostream.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator(ostream_type& s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostreambuf_iterator<char> i(outf);
+ assert(!i.failed());
+ }
+ {
+ std::wostringstream outf;
+ std::ostreambuf_iterator<wchar_t> i(outf);
+ assert(!i.failed());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp
new file mode 100644
index 0000000000000..1576b7d481a96
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.cons/streambuf.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator(streambuf_type* s) throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostreambuf_iterator<char> i(outf.rdbuf());
+ assert(!i.failed());
+ }
+ {
+ std::wostringstream outf;
+ std::ostreambuf_iterator<wchar_t> i(outf.rdbuf());
+ assert(!i.failed());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp
new file mode 100644
index 0000000000000..91d7b69279124
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/assign_c.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator<charT,traits>&
+// operator=(charT c);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostreambuf_iterator<char> i(outf);
+ i = 'a';
+ assert(outf.str() == "a");
+ i = 'b';
+ assert(outf.str() == "ab");
+ }
+ {
+ std::wostringstream outf;
+ std::ostreambuf_iterator<wchar_t> i(outf);
+ i = L'a';
+ assert(outf.str() == L"a");
+ i = L'b';
+ assert(outf.str() == L"ab");
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp
new file mode 100644
index 0000000000000..d086164102510
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/deref.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator<charT,traits>& operator*();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostreambuf_iterator<char> i(outf);
+ std::ostreambuf_iterator<char>& iref = *i;
+ assert(&iref == &i);
+ }
+ {
+ std::wostringstream outf;
+ std::ostreambuf_iterator<wchar_t> i(outf);
+ std::ostreambuf_iterator<wchar_t>& iref = *i;
+ assert(&iref == &i);
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp
new file mode 100644
index 0000000000000..9d93bad370d07
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/failed.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// bool failed() const throw();
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostreambuf_iterator<char> i(nullptr);
+ assert(i.failed());
+ }
+ {
+ std::ostreambuf_iterator<wchar_t> i(nullptr);
+ assert(i.failed());
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp
new file mode 100644
index 0000000000000..7461ce16347d6
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/ostreambuf.iter.ops/increment.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// class ostreambuf_iterator
+
+// ostreambuf_iterator<charT,traits>& operator++();
+// ostreambuf_iterator<charT,traits>& operator++(int);
+
+#include <iterator>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ std::ostringstream outf;
+ std::ostreambuf_iterator<char> i(outf);
+ std::ostreambuf_iterator<char>& iref = ++i;
+ assert(&iref == &i);
+ std::ostreambuf_iterator<char>& iref2 = i++;
+ assert(&iref2 == &i);
+ }
+ {
+ std::wostringstream outf;
+ std::ostreambuf_iterator<wchar_t> i(outf);
+ std::ostreambuf_iterator<wchar_t>& iref = ++i;
+ assert(&iref == &i);
+ std::ostreambuf_iterator<wchar_t>& iref2 = i++;
+ assert(&iref2 == &i);
+ }
+}
diff --git a/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp b/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
new file mode 100644
index 0000000000000..a699b2419830d
--- /dev/null
+++ b/test/std/iterators/stream.iterators/ostreambuf.iterator/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+// template <class charT, class traits = char_traits<charT> >
+// class ostreambuf_iterator
+// : public iterator<output_iterator_tag, void, void, void, void>
+// {
+// public:
+// typedef charT char_type;
+// typedef traits traits_type;
+// typedef basic_streambuf<charT, traits> streambuf_type;
+// typedef basic_ostream<charT, traits> ostream_type;
+// ...
+
+#include <iterator>
+#include <string>
+#include <type_traits>
+
+int main()
+{
+ typedef std::ostreambuf_iterator<char> I1;
+ static_assert((std::is_convertible<I1,
+ std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+ static_assert((std::is_same<I1::char_type, char>::value), "");
+ static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
+ static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
+ static_assert((std::is_same<I1::ostream_type, std::ostream>::value), "");
+
+ typedef std::ostreambuf_iterator<wchar_t> I2;
+ static_assert((std::is_convertible<I2,
+ std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+ static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
+ static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
+ static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
+ static_assert((std::is_same<I2::ostream_type, std::wostream>::value), "");
+}
diff --git a/test/std/iterators/version.pass.cpp b/test/std/iterators/version.pass.cpp
new file mode 100644
index 0000000000000..dd097850388e5
--- /dev/null
+++ b/test/std/iterators/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <iterator>
+
+#include <iterator>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}