2025-01-02 11:59:57 +01:00
|
|
|
// Copyright (C) 2010-2025 Free Software Foundation, Inc.
|
2010-01-12 00:53:30 +00:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
|
|
|
// Free Software Foundation; either version 3, or (at your option)
|
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this library; see the file COPYING3. If not see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
|
|
|
|
2012-11-14 23:33:01 +00:00
|
|
|
// 20.8.9 Function template bind
|
2010-01-12 00:53:30 +00:00
|
|
|
|
2016-08-17 14:39:10 +01:00
|
|
|
// { dg-options "-fno-show-column" }
|
|
|
|
// { dg-do compile { target c++11 } }
|
2010-01-12 00:53:30 +00:00
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
using namespace std::placeholders;
|
|
|
|
|
|
|
|
int inc(int& i) { return ++i; }
|
|
|
|
|
|
|
|
void test01()
|
|
|
|
{
|
|
|
|
const int dummy = 0;
|
2011-11-20 21:04:38 -05:00
|
|
|
std::bind(&inc, _1)(0); // { dg-error "no match" }
|
|
|
|
std::bind(&inc, std::ref(dummy))(); // { dg-error "no match" }
|
2010-01-12 00:53:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct Inc
|
|
|
|
{
|
|
|
|
int operator()(int& i) const { return ++i; }
|
|
|
|
void operator()(int&&) const { }
|
|
|
|
|
|
|
|
int f(int&& i) const { return ++i; }
|
|
|
|
};
|
|
|
|
|
|
|
|
void test02()
|
|
|
|
{
|
|
|
|
const int dummy = 0;
|
2011-06-10 10:20:28 -04:00
|
|
|
std::bind(Inc(), _1)(dummy); // { dg-error "no match" }
|
|
|
|
std::bind(&Inc::f, Inc(), std::ref(dummy))(); // { dg-error "no match" }
|
2010-01-12 00:53:30 +00:00
|
|
|
}
|
|
|
|
|
2016-08-17 14:39:10 +01:00
|
|
|
// Ignore the reasons for deduction/substitution failure in the headers.
|
2020-12-18 18:09:21 +00:00
|
|
|
// Arrange for the match to work on installed trees as well as build trees.
|
2024-03-19 14:02:06 +00:00
|
|
|
// { dg-prune-output "no type named 'type' in 'struct std::__invoke_result" }
|
2015-10-25 01:00:54 +01:00
|
|
|
|
2010-01-12 00:53:30 +00:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
test01();
|
|
|
|
test02();
|
|
|
|
}
|