summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-13 12:39:19 +0000
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-13 12:39:19 +0000
commit8cd5b37e243c6e27abda55fe172a0045cf7a1ebd (patch)
treef771e63ba9e58153e1af8040341106c963990059
parent2c4c3b287ebab2169480a76492e641081f55ee2c (diff)
downloadgcc-8cd5b37e243c6e27abda55fe172a0045cf7a1ebd.tar.gz
Restore __bind_simple for compat symbols
* src/c++11/compatibility-thread-c++0x.cc (_Bind_simple) (_Bind_simple_helper, __bind_simple): Restore for ABI compat symbols. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241111 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog3
-rw-r--r--libstdc++-v3/src/c++11/compatibility-thread-c++0x.cc62
2 files changed, 65 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index d08a8b1d966..1dac9caa868 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,8 @@
2016-10-13 Jonathan Wakely <jwakely@redhat.com>
+ * src/c++11/compatibility-thread-c++0x.cc (_Bind_simple)
+ (_Bind_simple_helper, __bind_simple): Restore for ABI compat symbols.
+
* include/std/functional (_Bind_simple, _Bind_simple_helper)
(__bind_simple): Remove.
* include/std/future: Include <bits/invoke.h> instead of <functional>.
diff --git a/libstdc++-v3/src/c++11/compatibility-thread-c++0x.cc b/libstdc++-v3/src/c++11/compatibility-thread-c++0x.cc
index 922fa0075ff..5ca2da8d22e 100644
--- a/libstdc++-v3/src/c++11/compatibility-thread-c++0x.cc
+++ b/libstdc++-v3/src/c++11/compatibility-thread-c++0x.cc
@@ -116,6 +116,68 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Replaced with inline definition in gcc-4.8.0
__future_base::_Async_state_common::~_Async_state_common() { _M_join(); }
+ template<typename _Signature>
+ struct _Bind_simple;
+
+ template<typename _Callable, typename... _Args>
+ struct _Bind_simple<_Callable(_Args...)>
+ {
+ typedef typename result_of<_Callable(_Args...)>::type result_type;
+
+ template<typename _Tp, typename... _Up>
+ explicit
+ _Bind_simple(_Tp&& __f, _Up&&... __args)
+ : _M_bound(std::forward<_Tp>(__f), std::forward<_Up>(__args)...)
+ { }
+
+ _Bind_simple(const _Bind_simple&) = default;
+ _Bind_simple(_Bind_simple&&) = default;
+
+ result_type
+ operator()()
+ {
+ typedef typename _Build_index_tuple<sizeof...(_Args)>::__type _Indices;
+ return _M_invoke(_Indices());
+ }
+
+ private:
+ template<std::size_t... _Indices>
+ typename result_of<_Callable(_Args...)>::type
+ _M_invoke(_Index_tuple<_Indices...>)
+ {
+ // std::bind always forwards bound arguments as lvalues,
+ // but this type can call functions which only accept rvalues.
+ return std::forward<_Callable>(std::get<0>(_M_bound))(
+ std::forward<_Args>(std::get<_Indices+1>(_M_bound))...);
+ }
+
+ std::tuple<_Callable, _Args...> _M_bound;
+ };
+
+ template<typename _Func, typename... _BoundArgs>
+ struct _Bind_simple_helper
+ {
+ typedef _Maybe_wrap_member_pointer<typename decay<_Func>::type>
+ __maybe_type;
+ typedef typename __maybe_type::type __func_type;
+ typedef _Bind_simple<__func_type(typename decay<_BoundArgs>::type...)>
+ __type;
+ };
+
+ // Simplified version of std::bind for internal use, without support for
+ // unbound arguments, placeholders or nested bind expressions.
+ template<typename _Callable, typename... _Args>
+ typename _Bind_simple_helper<_Callable, _Args...>::__type
+ __bind_simple(_Callable&& __callable, _Args&&... __args)
+ {
+ typedef _Bind_simple_helper<_Callable, _Args...> __helper_type;
+ typedef typename __helper_type::__maybe_type __maybe_type;
+ typedef typename __helper_type::__type __result_type;
+ return __result_type(
+ __maybe_type::__do_wrap( std::forward<_Callable>(__callable)),
+ std::forward<_Args>(__args)...);
+ }
+
// Explicit instantiation due to -fno-implicit-instantiation.
template void call_once(once_flag&, void (thread::*&&)(), reference_wrapper<thread>&&);
template _Bind_simple_helper<void (thread::*)(), reference_wrapper<thread>>::__type __bind_simple(void (thread::*&&)(), reference_wrapper<thread>&&);