2020-01-01 19:51:42 +08:00
|
|
|
// Copyright (C) 2015-2020 Free Software Foundation, Inc.
|
2015-12-15 22:17:17 +08: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/>.
|
|
|
|
|
2016-08-26 19:41:37 +08:00
|
|
|
// { dg-do compile { target c++11 } }
|
2015-12-15 22:17:17 +08:00
|
|
|
|
|
|
|
#include<functional>
|
|
|
|
|
|
|
|
struct Wrong {};
|
|
|
|
struct A {};
|
|
|
|
struct B {};
|
|
|
|
struct C{};
|
|
|
|
struct D{};
|
|
|
|
|
|
|
|
struct X {
|
|
|
|
A operator()(int, double) & { return {}; }
|
|
|
|
Wrong operator()(int, double) && {return {}; }
|
|
|
|
|
|
|
|
B operator()(int, double) const & { return {}; }
|
|
|
|
Wrong operator()(int, double) const && {return {}; }
|
|
|
|
|
|
|
|
C operator()(int, double) volatile & { return {}; }
|
|
|
|
Wrong operator()(int, double) volatile && {return {}; }
|
|
|
|
|
|
|
|
D operator()(int, double) const volatile & { return {}; }
|
|
|
|
Wrong operator()(int, double) const volatile && {return {}; }
|
|
|
|
};
|
|
|
|
|
|
|
|
void test01()
|
|
|
|
{
|
|
|
|
auto bound = std::bind(X{}, 5, std::placeholders::_1);
|
|
|
|
A res = bound(1.0);
|
|
|
|
const auto bound_c = bound;
|
|
|
|
B res_c = bound_c(1.0);
|
Make std::bind use std::invoke
* include/std/functional (_Mu<A, false, true>, _Mu<A, true, false>):
Simplify forwarding from tuple of references.
(_Maybe_wrap_member_pointer): Remove.
(_Bind::__call, _Bind::__call_c, _Bind::__call_v, _Bind::__call_c_v):
Use std::__invoke.
(_Bind::_Mu_type, _Bind::_Res_type_impl, _Bind::_Res_type)
(_Bind::__dependent, _Bind::_Res_type_cv): New helpers to simplify
return type deduction.
(_Bind::operator(), _Bind::operator() const): Use new helpers.
(_Bind::operator() volatile, _Bind::operator() const volatile):
Likewise. Add deprecated attribute for C++17 mode.
(_Bind_result::__call): Use std::__invoke.
(_Bind_result::operator() volatile)
(_Bind_result::operator() const volatile): Add deprecated attribute.
(_Bind_helper::__maybe_type, _Bindres_helper::__maybe_type): Remove.
(_Bind_helper, _Bindres_helper): Don't use _Maybe_wrap_member_pointer.
(bind, bind<R>): Don't use __maybe_type.
* src/c++11/compatibility-thread-c++0x.cc
(_Maybe_wrap_member_pointer): Define here for compatibility symbols.
* testsuite/20_util/bind/68912.cc: Don't test volatile-qualification
in C++17 mode.
* testsuite/20_util/bind/cv_quals.cc: Likewise.
* testsuite/20_util/bind/cv_quals_2.cc: Likewise.
From-SVN: r241178
2016-10-15 03:04:56 +08:00
|
|
|
#if __cplusplus <= 201402L
|
2015-12-15 22:17:17 +08:00
|
|
|
volatile auto bound_v = bound;
|
|
|
|
C res_v = bound_v(1.0);
|
|
|
|
volatile const auto bound_cv = bound;
|
|
|
|
D res_cv = bound_cv(1.0);
|
Make std::bind use std::invoke
* include/std/functional (_Mu<A, false, true>, _Mu<A, true, false>):
Simplify forwarding from tuple of references.
(_Maybe_wrap_member_pointer): Remove.
(_Bind::__call, _Bind::__call_c, _Bind::__call_v, _Bind::__call_c_v):
Use std::__invoke.
(_Bind::_Mu_type, _Bind::_Res_type_impl, _Bind::_Res_type)
(_Bind::__dependent, _Bind::_Res_type_cv): New helpers to simplify
return type deduction.
(_Bind::operator(), _Bind::operator() const): Use new helpers.
(_Bind::operator() volatile, _Bind::operator() const volatile):
Likewise. Add deprecated attribute for C++17 mode.
(_Bind_result::__call): Use std::__invoke.
(_Bind_result::operator() volatile)
(_Bind_result::operator() const volatile): Add deprecated attribute.
(_Bind_helper::__maybe_type, _Bindres_helper::__maybe_type): Remove.
(_Bind_helper, _Bindres_helper): Don't use _Maybe_wrap_member_pointer.
(bind, bind<R>): Don't use __maybe_type.
* src/c++11/compatibility-thread-c++0x.cc
(_Maybe_wrap_member_pointer): Define here for compatibility symbols.
* testsuite/20_util/bind/68912.cc: Don't test volatile-qualification
in C++17 mode.
* testsuite/20_util/bind/cv_quals.cc: Likewise.
* testsuite/20_util/bind/cv_quals_2.cc: Likewise.
From-SVN: r241178
2016-10-15 03:04:56 +08:00
|
|
|
#endif
|
2015-12-15 22:17:17 +08:00
|
|
|
}
|