| 1 |
// PR libstdc++/111327 - std::bind_front (and std::not_fn) doesn't always |
| 2 |
// perfectly forward according to value category of the call wrapper object |
| 3 |
// { dg-do compile { target c++20 } } |
| 4 |
|
| 5 |
#include <functional> |
| 6 |
#include <utility> |
| 7 |
|
| 8 |
struct F { |
| 9 |
void operator()(...) & = delete; |
| 10 |
void operator()(...) const &; |
| 11 |
}; |
| 12 |
|
| 13 |
struct G { |
| 14 |
void operator()(...) && = delete; |
| 15 |
void operator()(...) const &&; |
| 16 |
}; |
| 17 |
|
| 18 |
int main() { |
| 19 |
auto f0 = std::bind_front(F{}); |
| 20 |
f0(); // { dg-error "deleted|no match" } |
| 21 |
std::move(f0)(); |
| 22 |
std::as_const(f0)(); |
| 23 |
std::move(std::as_const(f0))(); |
| 24 |
|
| 25 |
auto g0 = std::bind_front(G{}); |
| 26 |
g0(); // { dg-error "deleted|no match" } |
| 27 |
std::move(g0)(); // { dg-error "deleted|no match" } |
| 28 |
std::move(std::as_const(g0))(); |
| 29 |
|
| 30 |
auto f1 = std::bind_front(F{}, 42); |
| 31 |
f1(); // { dg-error "deleted|no match" } |
| 32 |
std::move(f1)(); |
| 33 |
std::as_const(f1)(); |
| 34 |
std::move(std::as_const(f1))(); |
| 35 |
|
| 36 |
auto g1 = std::bind_front(G{}, 42); |
| 37 |
g1(); // { dg-error "deleted|no match" } |
| 38 |
std::move(g1)(); // { dg-error "deleted|no match" } |
| 39 |
std::move(std::as_const(g1))(); |
| 40 |
} |
| 41 |
|
| 42 |
// { dg-error "no type named 'type' in 'struct std::invoke_result" "" { target c++23 } 0 } |