[libcxx] r274210 - Make std::array typedef tests more portable.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 29 21:54:00 PDT 2016
Author: ericwf
Date: Wed Jun 29 23:54:00 2016
New Revision: 274210
URL: http://llvm.org/viewvc/llvm-project?rev=274210&view=rev
Log:
Make std::array typedef tests more portable.
Modified:
libcxx/trunk/test/std/containers/sequences/array/types.pass.cpp
Modified: libcxx/trunk/test/std/containers/sequences/array/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/types.pass.cpp?rev=274210&r1=274209&r2=274210&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/sequences/array/types.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/types.pass.cpp Wed Jun 29 23:54:00 2016
@@ -29,6 +29,25 @@
#include <iterator>
#include <type_traits>
+#include "test_macros.h"
+
+template <class C>
+void test_iterators() {
+ typedef std::iterator_traits<typename C::iterator> ItT;
+ typedef std::iterator_traits<typename C::const_iterator> CItT;
+ static_assert((std::is_same<typename ItT::iterator_category, std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<typename ItT::value_type, typename C::value_type>::value), "");
+ static_assert((std::is_same<typename ItT::reference, typename C::reference>::value), "");
+ static_assert((std::is_same<typename ItT::pointer, typename C::pointer>::value), "");
+ static_assert((std::is_same<typename ItT::difference_type, typename C::difference_type>::value), "");
+
+ static_assert((std::is_same<typename CItT::iterator_category, std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<typename CItT::value_type, typename C::value_type>::value), "");
+ static_assert((std::is_same<typename CItT::reference, typename C::const_reference>::value), "");
+ static_assert((std::is_same<typename CItT::pointer, typename C::const_pointer>::value), "");
+ static_assert((std::is_same<typename CItT::difference_type, typename C::difference_type>::value), "");
+}
+
int main()
{
{
@@ -36,8 +55,9 @@ int main()
typedef std::array<T, 10> C;
static_assert((std::is_same<C::reference, T&>::value), "");
static_assert((std::is_same<C::const_reference, const T&>::value), "");
- static_assert((std::is_same<C::iterator, T*>::value), "");
- static_assert((std::is_same<C::const_iterator, const T*>::value), "");
+ LIBCPP_STATIC_ASSERT((std::is_same<C::iterator, T*>::value), "");
+ LIBCPP_STATIC_ASSERT((std::is_same<C::const_iterator, const T*>::value), "");
+ test_iterators<C>();
static_assert((std::is_same<C::pointer, T*>::value), "");
static_assert((std::is_same<C::const_pointer, const T*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
@@ -57,8 +77,9 @@ int main()
typedef std::array<T, 0> C;
static_assert((std::is_same<C::reference, T&>::value), "");
static_assert((std::is_same<C::const_reference, const T&>::value), "");
- static_assert((std::is_same<C::iterator, T*>::value), "");
- static_assert((std::is_same<C::const_iterator, const T*>::value), "");
+ LIBCPP_STATIC_ASSERT((std::is_same<C::iterator, T*>::value), "");
+ LIBCPP_STATIC_ASSERT((std::is_same<C::const_iterator, const T*>::value), "");
+ test_iterators<C>();
static_assert((std::is_same<C::pointer, T*>::value), "");
static_assert((std::is_same<C::const_pointer, const T*>::value), "");
static_assert((std::is_same<C::size_type, std::size_t>::value), "");
More information about the cfe-commits
mailing list