Debian Codegraph @

libstdc++-v3/testsuite/20_util/pair/cons/99957.cc

raw
1 // { dg-options "-Wdeprecated" }
2 // { dg-add-options using-deprecated }
3 // { dg-do compile { target { c++11 && { ! c++20 } } } }
4
5 #include <utility>
6
7 using std::pair;
8
9 struct MoveOnly
10 {
11 MoveOnly() = default;
12 MoveOnly(MoveOnly&&) {}
13 };
14
15 struct ExplicitMoveOnly
16 {
17 ExplicitMoveOnly() = default;
18 ExplicitMoveOnly(ExplicitMoveOnly&&) {}
19 explicit ExplicitMoveOnly(MoveOnly&&) {}
20 };
21
22 // PR libstdc++/99957
23 // check non-standard constructors are deprecated
24
25 pair<int*, ExplicitMoveOnly> v14(0, MoveOnly{}); // { dg-warning "deprecated" }
26 pair<ExplicitMoveOnly, int*> v15(MoveOnly{}, 0); // { dg-warning "deprecated" }
27
28 pair<int*, MoveOnly> v16 = {0, MoveOnly{}}; // { dg-warning "deprecated" }
29 pair<MoveOnly, int*> v17 = {MoveOnly{}, 0}; // { dg-warning "deprecated" }
30
31 // PR libstdc++/101124
32 // check deprecated constructors don't cause unwanted ambiguities
33
34 std::pair<long*, int> p(0, 0); // { dg-bogus "ambiguous" }
35
36 struct X { } x;
37 std::pair<const X, void*> p2(x, 0); // { dg-bogus "ambiguous" }