[cfe-commits] [libcxx] r159857 - in /libcxx/trunk: include/tuple test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp

Howard Hinnant hhinnant at apple.com
Fri Jul 6 13:39:45 PDT 2012


Author: hhinnant
Date: Fri Jul  6 15:39:45 2012
New Revision: 159857

URL: http://llvm.org/viewvc/llvm-project?rev=159857&view=rev
Log:
Give tuple a constexpr default constructor.

Modified:
    libcxx/trunk/include/tuple
    libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp

Modified: libcxx/trunk/include/tuple
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=159857&r1=159856&r2=159857&view=diff
==============================================================================
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Fri Jul  6 15:39:45 2012
@@ -227,7 +227,7 @@
 
     __tuple_leaf& operator=(const __tuple_leaf&);
 public:
-    _LIBCPP_INLINE_VISIBILITY __tuple_leaf() : value()
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf() : value()
        {static_assert(!is_reference<_Hp>::value,
               "Attempted to default construct a reference element in a tuple");}
 
@@ -347,7 +347,7 @@
 
     __tuple_leaf& operator=(const __tuple_leaf&);
 public:
-    _LIBCPP_INLINE_VISIBILITY __tuple_leaf() {}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __tuple_leaf() {}
 
     template <class _Alloc>
         _LIBCPP_INLINE_VISIBILITY
@@ -436,6 +436,9 @@
 struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
     : public __tuple_leaf<_Indx, _Tp>...
 {
+    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR __tuple_impl() {}
+
     template <size_t ..._Uf, class ..._Tf,
               size_t ..._Ul, class ..._Tl, class ..._Up>
         _LIBCPP_INLINE_VISIBILITY
@@ -532,6 +535,9 @@
 public:
 
     _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR tuple() {}
+
+    _LIBCPP_INLINE_VISIBILITY
     explicit tuple(const _Tp& ... __t)
         : base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
                 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
@@ -687,7 +693,7 @@
 {
 public:
     _LIBCPP_INLINE_VISIBILITY
-    tuple() {}
+    _LIBCPP_CONSTEXPR tuple() {}
     template <class _Alloc>
     _LIBCPP_INLINE_VISIBILITY
         tuple(allocator_arg_t, const _Alloc&) {}

Modified: libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp?rev=159857&r1=159856&r2=159857&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp (original)
+++ libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp Fri Jul  6 15:39:45 2012
@@ -46,4 +46,18 @@
         assert(std::get<2>(t) == "");
         assert(std::get<3>(t) == DefaultOnly());
     }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+    {
+        constexpr std::tuple<> t;
+    }
+    {
+        constexpr std::tuple<int> t;
+        assert(std::get<0>(t) == 0);
+    }
+    {
+        constexpr std::tuple<int, char*> t;
+        assert(std::get<0>(t) == 0);
+        assert(std::get<1>(t) == nullptr);
+    }
+#endif
 }





More information about the cfe-commits mailing list