Commit de1d0794 by Jonathan Wakely Committed by Jonathan Wakely

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
parent 064ed55a
2016-10-14 Jonathan Wakely <jwakely@redhat.com> 2016-10-14 Jonathan Wakely <jwakely@redhat.com>
* 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.
* include/std/scoped_allocator (scoped_allocator_adaptor): Forward * include/std/scoped_allocator (scoped_allocator_adaptor): Forward
piecewise construction arguments as tuples of references, to avoid piecewise construction arguments as tuples of references, to avoid
copies (related to LWG 2511). copies (related to LWG 2511).
......
...@@ -116,6 +116,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -116,6 +116,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Replaced with inline definition in gcc-4.8.0 // Replaced with inline definition in gcc-4.8.0
__future_base::_Async_state_common::~_Async_state_common() { _M_join(); } __future_base::_Async_state_common::~_Async_state_common() { _M_join(); }
template<typename _Tp>
struct _Maybe_wrap_member_pointer;
template<typename _Tp, typename _Class>
struct _Maybe_wrap_member_pointer<_Tp _Class::*>
{
typedef _Mem_fn<_Tp _Class::*> type;
static constexpr type
__do_wrap(_Tp _Class::* __pm)
{ return type(__pm); }
};
template<typename _Signature> template<typename _Signature>
struct _Bind_simple; struct _Bind_simple;
......
...@@ -45,8 +45,10 @@ void test01() ...@@ -45,8 +45,10 @@ void test01()
A res = bound(1.0); A res = bound(1.0);
const auto bound_c = bound; const auto bound_c = bound;
B res_c = bound_c(1.0); B res_c = bound_c(1.0);
#if __cplusplus <= 201402L
volatile auto bound_v = bound; volatile auto bound_v = bound;
C res_v = bound_v(1.0); C res_v = bound_v(1.0);
volatile const auto bound_cv = bound; volatile const auto bound_cv = bound;
D res_cv = bound_cv(1.0); D res_cv = bound_cv(1.0);
#endif
} }
...@@ -48,11 +48,13 @@ void test01() ...@@ -48,11 +48,13 @@ void test01()
const auto b1 = std::bind(X()); const auto b1 = std::bind(X());
VERIFY( b1() == 1 ); VERIFY( b1() == 1 );
#if __cplusplus <= 201402L
volatile auto b2 = std::bind(X()); volatile auto b2 = std::bind(X());
VERIFY( b2() == 2 ); VERIFY( b2() == 2 );
const volatile auto b3 = std::bind(X()); const volatile auto b3 = std::bind(X());
VERIFY( b3() == 3 ); VERIFY( b3() == 3 );
#endif
} }
void test02() void test02()
...@@ -63,11 +65,13 @@ void test02() ...@@ -63,11 +65,13 @@ void test02()
const auto b1 = std::bind<int>(X()); const auto b1 = std::bind<int>(X());
VERIFY( b1() == 1 ); VERIFY( b1() == 1 );
#if __cplusplus <= 201402L
volatile auto b2 = std::bind<int>(X()); volatile auto b2 = std::bind<int>(X());
VERIFY( b2() == 2 ); VERIFY( b2() == 2 );
const volatile auto b3 = std::bind<int>(X()); const volatile auto b3 = std::bind<int>(X());
VERIFY( b3() == 3 ); VERIFY( b3() == 3 );
#endif
} }
void test03() void test03()
...@@ -78,11 +82,13 @@ void test03() ...@@ -78,11 +82,13 @@ void test03()
const auto b1 = std::bind(X(), _1, 0, _2); const auto b1 = std::bind(X(), _1, 0, _2);
VERIFY( b1(0, 0) == 1 ); VERIFY( b1(0, 0) == 1 );
#if __cplusplus <= 201402L
volatile auto b2 = std::bind(X(), _1, _2, 0); volatile auto b2 = std::bind(X(), _1, _2, 0);
VERIFY( b2(0, 0) == 2 ); VERIFY( b2(0, 0) == 2 );
const volatile auto b3 = std::bind(X(), _1, 0, _2); const volatile auto b3 = std::bind(X(), _1, 0, _2);
VERIFY( b3(0, 0) == 3 ); VERIFY( b3(0, 0) == 3 );
#endif
} }
void test04() void test04()
...@@ -93,11 +99,13 @@ void test04() ...@@ -93,11 +99,13 @@ void test04()
const auto b1 = std::bind<int>(X(), _1, 0, _2); const auto b1 = std::bind<int>(X(), _1, 0, _2);
VERIFY( b1(0, 0) == 1 ); VERIFY( b1(0, 0) == 1 );
#if __cplusplus <= 201402L
volatile auto b2 = std::bind<int>(X(), _1, _2, 0); volatile auto b2 = std::bind<int>(X(), _1, _2, 0);
VERIFY( b2(0, 0) == 2 ); VERIFY( b2(0, 0) == 2 );
const volatile auto b3 = std::bind<int>(X(), _1, 0, _2); const volatile auto b3 = std::bind<int>(X(), _1, 0, _2);
VERIFY( b3(0, 0) == 3 ); VERIFY( b3(0, 0) == 3 );
#endif
} }
......
...@@ -33,11 +33,13 @@ void test01() ...@@ -33,11 +33,13 @@ void test01()
const auto b0 = std::bind(X()); const auto b0 = std::bind(X());
VERIFY( b0() == 0 ); VERIFY( b0() == 0 );
#if __cplusplus <= 201402L
volatile auto b1 = std::bind(X()); volatile auto b1 = std::bind(X());
VERIFY( b1() == 1 ); VERIFY( b1() == 1 );
const volatile auto b2 = std::bind(X()); const volatile auto b2 = std::bind(X());
VERIFY( b2() == 2 ); VERIFY( b2() == 2 );
#endif
} }
int main() int main()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment