Home | History | Annotate | Download | only in tuple.elem
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // UNSUPPORTED: c++98, c++03, c++11
     11 
     12 #include <tuple>
     13 #include <string>
     14 #include "test_macros.h"
     15 
     16 struct UserType {};
     17 
     18 void test_bad_index() {
     19     std::tuple<long, long, char, std::string, char, UserType, char> t1;
     20     TEST_IGNORE_NODISCARD std::get<int>(t1); // expected-error@tuple:* {{type not found}}
     21     TEST_IGNORE_NODISCARD std::get<long>(t1); // expected-note {{requested here}}
     22     TEST_IGNORE_NODISCARD std::get<char>(t1); // expected-note {{requested here}}
     23         // expected-error@tuple:* 2 {{type occurs more than once}}
     24     std::tuple<> t0;
     25     TEST_IGNORE_NODISCARD std::get<char*>(t0); // expected-node {{requested here}}
     26         // expected-error@tuple:* 1 {{type not in empty type list}}
     27 }
     28 
     29 void test_bad_return_type() {
     30     typedef std::unique_ptr<int> upint;
     31     std::tuple<upint> t;
     32     upint p = std::get<upint>(t); // expected-error{{deleted copy constructor}}
     33 }
     34 
     35 int main()
     36 {
     37     test_bad_index();
     38     test_bad_return_type();
     39 }
     40