]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/reference_wrapper/lwg2993.cc
1 // Copyright (C) 2018-2022 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-do compile { target c++11 } }
22 // LWG 2993. reference_wrapper<T> conversion from T&&
24 static_assert(std::is_convertible
<std::reference_wrapper
<int>,
25 std::reference_wrapper
<const int>>::value
,
26 "LWG 2993 enables qualification conversions");
28 // The comments below are taken from the issue discussion and describe the
29 // behaviour before the resolution of LWG 2993. There should be no errors now.
31 struct convertible_from_int
{ convertible_from_int(int) { } };
37 void meow(std::reference_wrapper
<int>); //#1
38 void meow(convertible_from_int
); //#2
39 // error, ambiguous; would unambiguously call #2 if #1 instead took int&
46 std::reference_wrapper
<int> purr(); // { dg-warning "empty parentheses" }
48 // error, ambiguous: ICS exists from int prvalue to
49 // reference_wrapper<int> and from reference_wrapper<int> to int
50 auto x
= true ? purr() : 0;
52 // error: no member 'type' because the conditional
53 // expression is ill-formed
54 using t
= typename
std::common_type
<std::reference_wrapper
<int>, int>::type
;