This typedef uses the type before it's complete, which Clang rejects.
It's not necessary anyay, we can just use decltype directly where
needed. The _Invoker type isn't user-facing and doesn't need a
result_type.

        PR libstdc++/77998
        * include/std/future (__future_base::_Deferred_state)
        (__future_base::_Async_state_impl): Use decltype to deduce return
        type, instead of _Invoker::result_type.
        * include/std/thread (thread::_Invoker::operator()): Likewise.
        (thread::_Invoker::result_type): Remove.

Tested powerpc64le-linux, committed to trunk.

commit dfb18d127220b2a0f338d927253bbc5da4993f15
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Mon Oct 17 13:12:15 2016 +0100

    PR77998 Remove std::thread::_Invoker::result_type
    
        PR libstdc++/77998
        * include/std/future (__future_base::_Deferred_state)
        (__future_base::_Async_state_impl): Use decltype to deduce return
        type, instead of _Invoker::result_type.
        * include/std/thread (thread::_Invoker::operator()): Likewise.
        (thread::_Invoker::result_type): Remove.

diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index 31a21f9..5542d49 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -561,10 +561,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     class _Async_state_commonV2;
 #endif
 
-    template<typename _BoundFn, typename = typename _BoundFn::result_type>
+    template<typename _BoundFn,
+            typename _Res = decltype(std::declval<_BoundFn&>()())>
       class _Deferred_state;
 
-    template<typename _BoundFn, typename = typename _BoundFn::result_type>
+    template<typename _BoundFn,
+            typename _Res = decltype(std::declval<_BoundFn&>()())>
       class _Async_state_impl;
 
     template<typename _Signature>
diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread
index 7a3c407..576e577 100644
--- a/libstdc++-v3/include/std/thread
+++ b/libstdc++-v3/include/std/thread
@@ -235,14 +235,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        using _Indices
          = typename _Build_index_tuple<tuple_size<_Tuple>::value>::__type;
 
-       using result_type
-         = decltype(std::declval<_Invoker>()._M_invoke(_Indices()));
-
-       result_type
+       auto
        operator()()
-       noexcept(noexcept(std::declval<_Invoker>()._M_invoke(_Indices())))
+       noexcept(noexcept(std::declval<_Invoker&>()._M_invoke(_Indices())))
+       -> decltype(std::declval<_Invoker&>()._M_invoke(_Indices()))
        { return _M_invoke(_Indices()); }
-
       };
 
     // Alias for _Invoker<tuple<DECAY_COPY(_Tp)...>>

Reply via email to