| 1 |
// Copyright (C) 2015-2025 Free Software Foundation, Inc. |
| 2 |
// |
| 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) |
| 7 |
// any later version. |
| 8 |
|
| 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. |
| 13 |
|
| 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/>. |
| 17 |
|
| 18 |
// { dg-do compile { target c++11 } } |
| 19 |
|
| 20 |
#include<functional> |
| 21 |
|
| 22 |
struct Wrong {}; |
| 23 |
struct A {}; |
| 24 |
struct B {}; |
| 25 |
struct C{}; |
| 26 |
struct D{}; |
| 27 |
|
| 28 |
struct X { |
| 29 |
A operator()(int, double) & { return {}; } |
| 30 |
Wrong operator()(int, double) && {return {}; } |
| 31 |
|
| 32 |
B operator()(int, double) const & { return {}; } |
| 33 |
Wrong operator()(int, double) const && {return {}; } |
| 34 |
|
| 35 |
C operator()(int, double) volatile & { return {}; } |
| 36 |
Wrong operator()(int, double) volatile && {return {}; } |
| 37 |
|
| 38 |
D operator()(int, double) const volatile & { return {}; } |
| 39 |
Wrong operator()(int, double) const volatile && {return {}; } |
| 40 |
}; |
| 41 |
|
| 42 |
void test01() |
| 43 |
{ |
| 44 |
auto bound = std::bind(X{}, 5, std::placeholders::_1); |
| 45 |
A res = bound(1.0); |
| 46 |
const auto bound_c = bound; |
| 47 |
B res_c = bound_c(1.0); |
| 48 |
#if __cplusplus <= 201402L |
| 49 |
volatile auto bound_v = bound; |
| 50 |
C res_v = bound_v(1.0); |
| 51 |
volatile const auto bound_cv = bound; |
| 52 |
D res_cv = bound_cv(1.0); |
| 53 |
#endif |
| 54 |
} |