deferred
};
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // 2021. Further incorrect usages of result_of
template<typename _Fn, typename... _Args>
- future<typename result_of<_Fn(_Args...)>::type>
+ using __async_result_of = typename result_of<
+ typename decay<_Fn>::type(typename decay<_Args>::type...)>::type;
+
+ template<typename _Fn, typename... _Args>
+ future<__async_result_of<_Fn, _Args...>>
async(launch __policy, _Fn&& __fn, _Args&&... __args);
template<typename _Fn, typename... _Args>
- future<typename result_of<_Fn(_Args...)>::type>
+ future<__async_result_of<_Fn, _Args...>>
async(_Fn&& __fn, _Args&&... __args);
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \
friend class promise<_Res>;
template<typename> friend class packaged_task;
template<typename _Fn, typename... _Args>
- friend future<typename result_of<_Fn(_Args...)>::type>
+ friend future<__async_result_of<_Fn, _Args...>>
async(launch, _Fn&&, _Args&&...);
typedef __basic_future<_Res> _Base_type;
friend class promise<_Res&>;
template<typename> friend class packaged_task;
template<typename _Fn, typename... _Args>
- friend future<typename result_of<_Fn(_Args...)>::type>
+ friend future<__async_result_of<_Fn, _Args...>>
async(launch, _Fn&&, _Args&&...);
typedef __basic_future<_Res&> _Base_type;
friend class promise<void>;
template<typename> friend class packaged_task;
template<typename _Fn, typename... _Args>
- friend future<typename result_of<_Fn(_Args...)>::type>
+ friend future<__async_result_of<_Fn, _Args...>>
async(launch, _Fn&&, _Args&&...);
typedef __basic_future<void> _Base_type;
/// async
template<typename _Fn, typename... _Args>
- future<typename result_of<_Fn(_Args...)>::type>
+ future<__async_result_of<_Fn, _Args...>>
async(launch __policy, _Fn&& __fn, _Args&&... __args)
{
- typedef typename result_of<_Fn(_Args...)>::type result_type;
std::shared_ptr<__future_base::_State_base> __state;
if ((__policy & launch::async) == launch::async)
{
__state = __future_base::_S_make_deferred_state(std::__bind_simple(
std::forward<_Fn>(__fn), std::forward<_Args>(__args)...));
}
- return future<result_type>(__state);
+ return future<__async_result_of<_Fn, _Args...>>(__state);
}
/// async, potential overload
template<typename _Fn, typename... _Args>
- inline future<typename result_of<_Fn(_Args...)>::type>
+ inline future<__async_result_of<_Fn, _Args...>>
async(_Fn&& __fn, _Args&&... __args)
{
- return async(launch::async|launch::deferred, std::forward<_Fn>(__fn),
- std::forward<_Args>(__args)...);
+ return std::async(launch::async|launch::deferred,
+ std::forward<_Fn>(__fn),
+ std::forward<_Args>(__args)...);
}
#endif // _GLIBCXX_ASYNC_ABI_COMPAT
--- /dev/null
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// 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/>.
+
+// { dg-do compile { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
+// { dg-options " -std=gnu++11 -pthread" { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } }
+// { dg-options " -std=gnu++11 -pthreads" { target *-*-solaris* } }
+// { dg-options " -std=gnu++11 " { target *-*-cygwin *-*-darwin* } }
+// { dg-require-cstdint "" }
+// { dg-require-gthreads "" }
+// { dg-require-atomic-builtins "" }
+
+// LWG 2021. Further incorrect usages of result_of
+// Arguments to result_of should use decay.
+
+#include <future>
+
+struct A
+{
+ int operator()(int&&)&& { return 0; }
+ void operator()(int&)& { }
+};
+
+int main()
+{
+ A a;
+ int i = 0;
+ std::future<int> f = std::async(a, i);
+}