77 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// UNSUPPORTED: c++0310 11// This test makes sure that we can copy/move a std::tuple containing a type12// that checks for copy constructibility itself, like std::any.13//14// Problem showcased in https://reviews.llvm.org/D96523#2730953.15 16#include <any>17#include <tuple>18#include <type_traits>19#include <utility>20 21#include "test_macros.h"22 23template <class ...Pred>24struct And : std::true_type { };25 26template <class P1, class ...Pn>27struct And<P1, Pn...>28 : std::conditional<P1::value, And<Pn...>, std::false_type>::type29{ };30 31struct any {32 any();33 any(any const&) = default;34 35 template <class ValueType,36 class Decayed = typename std::decay<ValueType>::type,37 class = typename std::enable_if<38 !std::is_same<Decayed, any>::value &&39 std::is_copy_constructible<Decayed>::value40 >::type>41 any(ValueType&&);42};43 44struct A {45 A();46 A(any);47};48 49#if TEST_STD_VER > 1450struct B {51 B();52 B(std::any);53};54#endif55 56void f() {57 {58 std::tuple<A, int> x;59 std::tuple<A, int> y = x; (void)y;60 }61 {62 std::tuple<A, int> x;63 std::tuple<A, int> y = std::move(x); (void)y;64 }65 66#if TEST_STD_VER > 1467 {68 std::tuple<B, int> x;69 std::tuple<B, int> y = x; (void)y;70 }71 {72 std::tuple<B, int> x;73 std::tuple<B, int> y = std::move(x); (void)y;74 }75#endif76}77