[libcxx] r224295 - Add test to ensure that iterator_traits<NotAnIterator> doesn't have a value type

Marshall Clow mclow.lists at gmail.com
Mon Dec 15 16:30:08 PST 2014


Author: marshall
Date: Mon Dec 15 18:30:07 2014
New Revision: 224295

URL: http://llvm.org/viewvc/llvm-project?rev=224295&view=rev
Log:
Add test to ensure that iterator_traits<NotAnIterator> doesn't have a value type

Modified:
    libcxx/trunk/test/iterators/iterator.primitives/iterator.traits/empty.pass.cpp

Modified: libcxx/trunk/test/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/iterators/iterator.primitives/iterator.traits/empty.pass.cpp?rev=224295&r1=224294&r2=224295&view=diff
==============================================================================
--- libcxx/trunk/test/iterators/iterator.primitives/iterator.traits/empty.pass.cpp (original)
+++ libcxx/trunk/test/iterators/iterator.primitives/iterator.traits/empty.pass.cpp Mon Dec 15 18:30:07 2014
@@ -20,7 +20,19 @@ 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), "");
 }





More information about the cfe-commits mailing list