[libcxx] r274422 - Handle std::get<T>(...) for std::tuple<>

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 1 20:46:08 PDT 2016


Author: ericwf
Date: Fri Jul  1 22:46:08 2016
New Revision: 274422

URL: http://llvm.org/viewvc/llvm-project?rev=274422&view=rev
Log:
Handle std::get<T>(...) for std::tuple<>

Modified:
    libcxx/trunk/include/tuple
    libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp

Modified: libcxx/trunk/include/tuple
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=274422&r1=274421&r2=274422&view=diff
==============================================================================
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Fri Jul  1 22:46:08 2016
@@ -1013,6 +1013,11 @@ struct __find_exactly_one_checked {
     static_assert(value != __ambiguous,"type occurs more than once in type list");
 };
 
+template <class _T1>
+struct __find_exactly_one_checked<_T1> {
+    static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
+};
+
 } // namespace __find_detail;
 
 template <typename _T1, typename... _Args>

Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp?rev=274422&r1=274421&r2=274422&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp (original)
+++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp Fri Jul  1 22:46:08 2016
@@ -20,6 +20,9 @@ void test_bad_index() {
     (void)std::get<long>(t1); // expected-note {{requested here}}
     (void)std::get<char>(t1); // expected-note {{requested here}}
         // expected-error at tuple:* 2 {{type occurs more than once}}
+    std::tuple<> t0;
+    (void)std::get<char*>(t0); // expected-node {{requested here}}
+        // expected-error at tuple:* 1 {{type not in empty type list}}
 }
 
 void test_bad_return_type() {




More information about the cfe-commits mailing list