[PATCH] D21876: [libcxx] [test] Make istreambuf.iterator/types.pass.cpp more portable.

Stephan T. Lavavej via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 29 16:38:11 PDT 2016


STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.

Make istreambuf.iterator/types.pass.cpp more portable.

There are two issues here. First, istreambuf_iterator::pointer is unspecified (and MSVC uses a different type). Second, C++17 doesn't mandate std::iterator inheritance anymore (MSVC currently inherits, but we'll probably change this in the future).

These changes future-proof the test by inspecting the typedefs, and marking the pointer static_assert as libcxx-specific.

http://reviews.llvm.org/D21876

Files:
  test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp

Index: test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp
===================================================================
--- test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp
+++ test/std/iterators/stream.iterators/istreambuf.iterator/types.pass.cpp
@@ -33,12 +33,16 @@
 #include <string>
 #include <type_traits>
 
+#include "test_macros.h"
+
 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::iterator_category, std::input_iterator_tag>::value), "");
+    static_assert((std::is_same<I1::value_type, char>::value), "");
+    static_assert((std::is_same<I1::difference_type, std::char_traits<char>::off_type>::value), "");
+    LIBCPP_STATIC_ASSERT((std::is_same<I1::pointer, char*>::value), "");
+    static_assert((std::is_same<I1::reference, 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), "");
@@ -49,9 +53,11 @@
     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::iterator_category, std::input_iterator_tag>::value), "");
+    static_assert((std::is_same<I2::value_type, wchar_t>::value), "");
+    static_assert((std::is_same<I2::difference_type, std::char_traits<wchar_t>::off_type>::value), "");
+    LIBCPP_STATIC_ASSERT((std::is_same<I2::pointer, wchar_t*>::value), "");
+    static_assert((std::is_same<I2::reference, 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), "");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21876.62309.patch
Type: text/x-patch
Size: 2270 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160629/d8ef8da6/attachment-0001.bin>


More information about the cfe-commits mailing list