35 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// <utility>12 13// template <class T1, class T2> struct pair14 15// explicit(see-below) constexpr pair();16 17// This test checks the conditional explicitness of std::pair's default18// constructor as introduced by the resolution of https://wg21.link/LWG2510.19 20#include <utility>21 22 23struct ImplicitlyDefaultConstructible {24 ImplicitlyDefaultConstructible() = default;25};26 27struct ExplicitlyDefaultConstructible {28 explicit ExplicitlyDefaultConstructible() = default;29};30 31std::pair<ImplicitlyDefaultConstructible, ExplicitlyDefaultConstructible> test1() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}32std::pair<ExplicitlyDefaultConstructible, ImplicitlyDefaultConstructible> test2() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}33std::pair<ExplicitlyDefaultConstructible, ExplicitlyDefaultConstructible> test3() { return {}; } // expected-error 1 {{chosen constructor is explicit in copy-initialization}}34std::pair<ImplicitlyDefaultConstructible, ImplicitlyDefaultConstructible> test4() { return {}; }35