61 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// <tuple>10 11// template <class... Types> class tuple;12 13// template <class U1, class U2> tuple(pair<U1, U2>&& u);14 15// UNSUPPORTED: c++0316 17#include <tuple>18#include <utility>19#include <memory>20#include <cassert>21 22#include "test_macros.h"23 24struct B25{26 int id_;27 28 explicit B(int i) : id_(i) {}29 30 virtual ~B() {}31};32 33struct D34 : B35{36 explicit D(int i) : B(i) {}37};38 39int main(int, char**)40{41 {42 typedef std::pair<long, std::unique_ptr<D>> T0;43 typedef std::tuple<long long, std::unique_ptr<B>> T1;44 T0 t0(2, std::unique_ptr<D>(new D(3)));45 T1 t1 = std::move(t0);46 assert(std::get<0>(t1) == 2);47 assert(std::get<1>(t1)->id_ == 3);48 }49 50#if TEST_STD_VER > 1151 {52 using pair_t = std::pair<int, char>;53 constexpr std::tuple<long, long> t(pair_t(0, 'a'));54 static_assert(std::get<0>(t) == 0, "");55 static_assert(std::get<1>(t) == 'a', "");56 }57#endif58 59 return 0;60}61