[cfe-commits] [libcxx] r111542 - in /libcxx/trunk: include/tuple test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp test/utilities/tuple/tuple.tuple/tuple.creation/pack_arguments.pass.cpp

Howard Hinnant hhinnant at apple.com
Thu Aug 19 11:59:39 PDT 2010


Author: hhinnant
Date: Thu Aug 19 13:59:38 2010
New Revision: 111542

URL: http://llvm.org/viewvc/llvm-project?rev=111542&view=rev
Log:
US 98, US 99

Added:
    libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp
      - copied, changed from r111330, libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/pack_arguments.pass.cpp
Removed:
    libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/pack_arguments.pass.cpp
Modified:
    libcxx/trunk/include/tuple

Modified: libcxx/trunk/include/tuple
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=111542&r1=111541&r2=111542&view=diff
==============================================================================
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Thu Aug 19 13:59:38 2010
@@ -72,6 +72,7 @@
 const unspecified ignore;
 
 template <class... T> tuple<V...>  make_tuple(T&&...);
+template <class... T> tuple<ATypes...> forward_as_tuple(T&&...);
 template <class... T> tuple<T&...> tie(T&...);
 template <class... T, class... U> tuple<T..., U...> tuple_cat(const tuple<T...>&, const tuple<U...>&);
 template <class... T, class... U> tuple<T..., U...> tuple_cat(tuple<T...>&&, const tuple<U...>&);
@@ -621,6 +622,14 @@
     return tuple<typename __make_tuple_return<_Tp>::type...>(_STD::forward<_Tp>(__t)...);
 }
 
+template <class... _Tp>
+inline
+tuple<_Tp&&...>
+forward_as_tuple(_Tp&&... __t)
+{
+    return tuple<_Tp&&...>(_STD::forward<_Tp>(__t)...);
+}
+
 template <size_t _I>
 struct __tuple_equal
 {

Copied: libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp (from r111330, libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/pack_arguments.pass.cpp)
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp?p2=libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp&p1=libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/pack_arguments.pass.cpp&r1=111330&r2=111542&rev=111542&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/pack_arguments.pass.cpp (original)
+++ libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp Thu Aug 19 13:59:38 2010
@@ -10,12 +10,63 @@
 // <tuple>
 
 // template<class... Types>
-//     tuple<ATypes...> pack_arguments(Types&&... t);
+//     tuple<Types&&...> forward_as_tuple(Types&&... t);
 
 
 #include <tuple>
+#include <cassert>
+
+template <class Tuple>
+void
+test0(const Tuple& t)
+{
+    static_assert(std::tuple_size<Tuple>::value == 0, "");
+}
+
+template <class Tuple>
+void
+test1a(const Tuple& t)
+{
+    static_assert(std::tuple_size<Tuple>::value == 1, "");
+    static_assert(std::is_same<typename std::tuple_element<0, Tuple>::type, int&&>::value, "");
+    assert(std::get<0>(t) == 1);
+}
+
+template <class Tuple>
+void
+test1b(const Tuple& t)
+{
+    static_assert(std::tuple_size<Tuple>::value == 1, "");
+    static_assert(std::is_same<typename std::tuple_element<0, Tuple>::type, int&>::value, "");
+    assert(std::get<0>(t) == 2);
+}
+
+template <class Tuple>
+void
+test2a(const Tuple& t)
+{
+    static_assert(std::tuple_size<Tuple>::value == 2, "");
+    static_assert(std::is_same<typename std::tuple_element<0, Tuple>::type, double&>::value, "");
+    static_assert(std::is_same<typename std::tuple_element<1, Tuple>::type, char&>::value, "");
+    assert(std::get<0>(t) == 2.5);
+    assert(std::get<1>(t) == 'a');
+}
 
 int main()
 {
-#error pack_arguments not implemented
+    {
+        test0(std::forward_as_tuple());
+    }
+    {
+        test1a(std::forward_as_tuple(1));
+    }
+    {
+        int i = 2;
+        test1b(std::forward_as_tuple(i));
+    }
+    {
+        double i = 2.5;
+        char c = 'a';
+        test2a(std::forward_as_tuple(i, c));
+    }
 }

Removed: libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/pack_arguments.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/pack_arguments.pass.cpp?rev=111541&view=auto
==============================================================================
--- libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/pack_arguments.pass.cpp (original)
+++ libcxx/trunk/test/utilities/tuple/tuple.tuple/tuple.creation/pack_arguments.pass.cpp (removed)
@@ -1,21 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <tuple>
-
-// template<class... Types>
-//     tuple<ATypes...> pack_arguments(Types&&... t);
-
-
-#include <tuple>
-
-int main()
-{
-#error pack_arguments not implemented
-}





More information about the cfe-commits mailing list