brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 93f8fbc Raw
52 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// UNSUPPORTED: c++0314 15// Test the following constructors:16// (1) tuple(Types const&...)17// (2) tuple(UTypes&&...)18// Test that (1) short circuits before evaluating the copy constructor of the19// second argument. Constructor (2) should be selected.20 21#include <tuple>22#include <utility>23#include <cassert>24 25#include "test_macros.h"26 27struct NonConstCopyable {28  NonConstCopyable() = default;29  explicit NonConstCopyable(int v) : value(v) {}30  NonConstCopyable(NonConstCopyable&) = default;31  NonConstCopyable(NonConstCopyable const&) = delete;32  int value;33};34 35template <class T>36struct BlowsUpOnConstCopy {37  BlowsUpOnConstCopy() = default;38  constexpr BlowsUpOnConstCopy(BlowsUpOnConstCopy const&) {39      static_assert(!std::is_same<T, T>::value, "");40  }41  BlowsUpOnConstCopy(BlowsUpOnConstCopy&) = default;42};43 44int main(int, char**) {45  NonConstCopyable v(42);46  BlowsUpOnConstCopy<int> b;47  std::tuple<NonConstCopyable, BlowsUpOnConstCopy<int>> t(v, b);48  assert(std::get<0>(t).value == 42);49 50  return 0;51}52