]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/function_objects/mem_fn/55463.cc
1 // { dg-do compile { target c++11 } }
3 // Copyright (C) 2012-2019 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // PR libstdc++/55463 Passing rvalue objects to std::mem_fn
28 short& func_v() volatile;
29 double& func_cv() const volatile;
46 std::reference_wrapper
<X
> ref();
47 std::reference_wrapper
<const X
> cref();
48 std::reference_wrapper
<Y
> yref();
52 int& i1
__attribute__((unused
)) = std::mem_fn( &X::func
)( X() );
53 int& i2
__attribute__((unused
)) = std::mem_fn( &X::func
)( Y() );
54 int& i3
__attribute__((unused
)) = std::mem_fn( &X::func
)( ref() );
55 int& i4
__attribute__((unused
)) = std::mem_fn( &X::func
)( yref() );
56 int& i5
__attribute__((unused
)) = std::mem_fn( &X::func
)( X_ptr() );
57 int& i6
__attribute__((unused
)) = std::mem_fn( &X::func
)( smart_ptr() );
59 char& c1
__attribute__((unused
)) = std::mem_fn( &X::func_c
)( X() );
60 char& c2
__attribute__((unused
)) = std::mem_fn( &X::func_c
)( CX() );
61 char& c3
__attribute__((unused
)) = std::mem_fn( &X::func_c
)( Y() );
62 char& c4
__attribute__((unused
)) = std::mem_fn( &X::func_c
)( ref() );
63 char& c5
__attribute__((unused
)) = std::mem_fn( &X::func_c
)( cref() );
64 char& c6
__attribute__((unused
)) = std::mem_fn( &X::func_c
)( yref() );
65 char& c7
__attribute__((unused
)) = std::mem_fn( &X::func_c
)( X_ptr() );
66 char& c8
__attribute__((unused
)) = std::mem_fn( &X::func_c
)( smart_ptr() );
68 short& s1
__attribute__((unused
)) = std::mem_fn( &X::func_v
)( X() );
69 short& s2
__attribute__((unused
)) = std::mem_fn( &X::func_v
)( Y() );
70 short& s3
__attribute__((unused
)) = std::mem_fn( &X::func_v
)( ref() );
71 short& s4
__attribute__((unused
)) = std::mem_fn( &X::func_v
)( yref() );
72 short& s5
__attribute__((unused
)) = std::mem_fn( &X::func_v
)( X_ptr() );
73 short& s6
__attribute__((unused
)) = std::mem_fn( &X::func_v
)( smart_ptr() );
75 double& d1
__attribute__((unused
)) = std::mem_fn( &X::func_cv
)( X() );
76 double& d2
__attribute__((unused
)) = std::mem_fn( &X::func_cv
)( CX() );
77 double& d3
__attribute__((unused
)) = std::mem_fn( &X::func_cv
)( Y() );
78 double& d4
__attribute__((unused
)) = std::mem_fn( &X::func_cv
)( ref() );
79 double& d5
__attribute__((unused
)) = std::mem_fn( &X::func_cv
)( cref() );
80 double& d6
__attribute__((unused
)) = std::mem_fn( &X::func_cv
)( yref() );
81 double& d7
__attribute__((unused
)) = std::mem_fn( &X::func_cv
)( X_ptr() );
82 double& d8
__attribute__((unused
))
83 = std::mem_fn( &X::func_cv
)( smart_ptr() );
86 // The result of a .* expression whose second operand is a pointer to a
87 // data member is of the same value category (3.10) as its first operand.
88 int&& rval
__attribute__((unused
)) = std::mem_fn( &X::data
)( X() );
89 const int&& crval
__attribute__((unused
)) = std::mem_fn( &X::data
)( CX() );
90 int&& yrval
__attribute__((unused
)) = std::mem_fn( &X::data
)( Y() );
91 const int&& ycrval
__attribute__((unused
)) = std::mem_fn( &X::data
)( CY() );
93 int& val
__attribute__((unused
)) = std::mem_fn( &X::data
)( ref() );
94 const int& cval
__attribute__((unused
)) = std::mem_fn( &X::data
)( cref() );
95 int& yval
__attribute__((unused
)) = std::mem_fn( &X::data
)( yref() );
97 int& pval
__attribute__((unused
)) = std::mem_fn( &X::data
)( X_ptr() );
98 int& sval
__attribute__((unused
)) = std::mem_fn( &X::data
)( smart_ptr() );