blob: a808019e28e6000d3c22ca8a2d9be5d9aee2c5b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// P0847R7
// { dg-do run { target c++23 } }
// calling captureless lambda call operator with unrelated explicit object parameter
// through function pointer
int main()
{
auto f0 = [](this auto self) { return self; };
auto fp0_value = static_cast<int(*)(int) >(&decltype(f0)::operator());
auto fp0_lref = static_cast<int(*)(int&) >(&decltype(f0)::operator());
auto fp0_rref = static_cast<int(*)(int&&) >(&decltype(f0)::operator());
auto fp0_constlref = static_cast<int(*)(int const&) >(&decltype(f0)::operator());
auto fp0_constrref = static_cast<int(*)(int const&&)>(&decltype(f0)::operator());
auto f1 = [](this auto&& self) { return self; };
auto fp1_lref = static_cast<int(*)(int&) >(&decltype(f1)::operator());
auto fp1_rref = static_cast<int(*)(int&&) >(&decltype(f1)::operator());
auto fp1_constlref = static_cast<int(*)(int const&) >(&decltype(f1)::operator());
auto fp1_constrref = static_cast<int(*)(int const&&)>(&decltype(f1)::operator());
// both are needed for lvalue/rvalue overloads
#define MAGIC 42
int magic = MAGIC;
if (fp0_value (magic) != magic)
__builtin_abort ();
if (fp0_lref (magic) != magic)
__builtin_abort ();
if (fp0_rref (MAGIC) != magic)
__builtin_abort ();
if (fp0_constlref (magic) != magic)
__builtin_abort ();
if (fp0_constrref (MAGIC) != magic)
__builtin_abort ();
if (fp1_lref (magic) != magic)
__builtin_abort ();
if (fp1_rref (MAGIC) != magic)
__builtin_abort ();
if (fp1_constlref (magic) != magic)
__builtin_abort ();
if (fp1_constrref (MAGIC) != magic)
__builtin_abort ();
}
|