1 // Copyright (C) 2015-2016 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-options "-std=gnu++11" }
19 // { dg-do compile }
20
21 #include<functional>
22
23 struct Wrong {};
24 struct A {};
25 struct B {};
26 struct C{};
27 struct D{};
28
29 struct X {
operator ()X30 A operator()(int, double) & { return {}; }
operator ()X31 Wrong operator()(int, double) && {return {}; }
32
operator ()X33 B operator()(int, double) const & { return {}; }
operator ()X34 Wrong operator()(int, double) const && {return {}; }
35
operator ()X36 C operator()(int, double) volatile & { return {}; }
operator ()X37 Wrong operator()(int, double) volatile && {return {}; }
38
operator ()X39 D operator()(int, double) const volatile & { return {}; }
operator ()X40 Wrong operator()(int, double) const volatile && {return {}; }
41 };
42
test01()43 void test01()
44 {
45 auto bound = std::bind(X{}, 5, std::placeholders::_1);
46 A res = bound(1.0);
47 const auto bound_c = bound;
48 B res_c = bound_c(1.0);
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 }
54