[libcxx] r302318 - [libcxx] [test] Be compatible with LWG 2438 "std::iterator inheritance shouldn't be mandated".

Stephan T. Lavavej via cfe-commits cfe-commits at lists.llvm.org
Fri May 5 16:01:39 PDT 2017


Author: stl_msft
Date: Fri May  5 18:01:38 2017
New Revision: 302318

URL: http://llvm.org/viewvc/llvm-project?rev=302318&view=rev
Log:
[libcxx] [test] Be compatible with LWG 2438 "std::iterator inheritance shouldn't be mandated".

In C++17, these iterators are allowed but not required
to inherit from the deprecated std::iterator base class.

Fixes D32727.

Modified:
    libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
    libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
    libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp

Modified: libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp?rev=302318&r1=302317&r2=302318&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp Fri May  5 18:01:38 2017
@@ -40,12 +40,22 @@
 #include <type_traits>
 #include <string>
 
+#include "test_macros.h"
+
 int main()
 {
     typedef std::istream_iterator<double> I1; // double is trivially destructible
+#if TEST_STD_VER <= 14
     static_assert((std::is_convertible<I1,
         std::iterator<std::input_iterator_tag, double, std::ptrdiff_t,
         const double*, const double&> >::value), "");
+#else
+    static_assert((std::is_same<I1::iterator_category, std::input_iterator_tag>::value), "");
+    static_assert((std::is_same<I1::value_type, double>::value), "");
+    static_assert((std::is_same<I1::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<I1::pointer, const double*>::value), "");
+    static_assert((std::is_same<I1::reference, const double&>::value), "");
+#endif
     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), "");
@@ -53,9 +63,17 @@ int main()
     static_assert( std::is_trivially_destructible<I1>::value, "");
 
     typedef std::istream_iterator<unsigned, wchar_t> I2; // unsigned is trivially destructible
+#if TEST_STD_VER <= 14
     static_assert((std::is_convertible<I2,
         std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t,
         const unsigned*, const unsigned&> >::value), "");
+#else
+    static_assert((std::is_same<I2::iterator_category, std::input_iterator_tag>::value), "");
+    static_assert((std::is_same<I2::value_type, unsigned>::value), "");
+    static_assert((std::is_same<I2::difference_type, std::ptrdiff_t>::value), "");
+    static_assert((std::is_same<I2::pointer, const unsigned*>::value), "");
+    static_assert((std::is_same<I2::reference, const unsigned&>::value), "");
+#endif
     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), "");

Modified: libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp?rev=302318&r1=302317&r2=302318&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp Fri May  5 18:01:38 2017
@@ -23,17 +23,35 @@
 #include <iterator>
 #include <type_traits>
 
+#include "test_macros.h"
+
 int main()
 {
     typedef std::ostream_iterator<double> I1;
+#if TEST_STD_VER <= 14
     static_assert((std::is_convertible<I1,
         std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+#else
+    static_assert((std::is_same<I1::iterator_category, std::output_iterator_tag>::value), "");
+    static_assert((std::is_same<I1::value_type, void>::value), "");
+    static_assert((std::is_same<I1::difference_type, void>::value), "");
+    static_assert((std::is_same<I1::pointer, void>::value), "");
+    static_assert((std::is_same<I1::reference, void>::value), "");
+#endif
     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;
+#if TEST_STD_VER <= 14
     static_assert((std::is_convertible<I2,
         std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+#else
+    static_assert((std::is_same<I2::iterator_category, std::output_iterator_tag>::value), "");
+    static_assert((std::is_same<I2::value_type, void>::value), "");
+    static_assert((std::is_same<I2::difference_type, void>::value), "");
+    static_assert((std::is_same<I2::pointer, void>::value), "");
+    static_assert((std::is_same<I2::reference, void>::value), "");
+#endif
     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), "");

Modified: libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp?rev=302318&r1=302317&r2=302318&view=diff
==============================================================================
--- libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp (original)
+++ libcxx/trunk/test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp Fri May  5 18:01:38 2017
@@ -24,19 +24,37 @@
 #include <string>
 #include <type_traits>
 
+#include "test_macros.h"
+
 int main()
 {
     typedef std::ostreambuf_iterator<char> I1;
+#if TEST_STD_VER <= 14
     static_assert((std::is_convertible<I1,
         std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+#else
+    static_assert((std::is_same<I1::iterator_category, std::output_iterator_tag>::value), "");
+    static_assert((std::is_same<I1::value_type, void>::value), "");
+    static_assert((std::is_same<I1::difference_type, void>::value), "");
+    static_assert((std::is_same<I1::pointer, void>::value), "");
+    static_assert((std::is_same<I1::reference, void>::value), "");
+#endif
     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;
+#if TEST_STD_VER <= 14
     static_assert((std::is_convertible<I2,
         std::iterator<std::output_iterator_tag, void, void, void, void> >::value), "");
+#else
+    static_assert((std::is_same<I2::iterator_category, std::output_iterator_tag>::value), "");
+    static_assert((std::is_same<I2::value_type, void>::value), "");
+    static_assert((std::is_same<I2::difference_type, void>::value), "");
+    static_assert((std::is_same<I2::pointer, void>::value), "");
+    static_assert((std::is_same<I2::reference, void>::value), "");
+#endif
     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), "");




More information about the cfe-commits mailing list