Skip to content

Commit

Permalink
Add workarounds for bugs in Intel C++ compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Feb 13, 2015
1 parent 0860499 commit 4613fa0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions include/async++/scheduler_fwd.h
Expand Up @@ -164,4 +164,10 @@ class threadpool_scheduler {
LIBASYNC_EXPORT void schedule(task_run_handle t);
};

namespace detail {

// Work-around for Intel compiler handling decltype poorly in function returns
typedef std::remove_reference<decltype(::async::default_scheduler())>::type default_scheduler_type;

} // namespace detail
} // namespace async
9 changes: 6 additions & 3 deletions include/async++/task.h
Expand Up @@ -402,7 +402,7 @@ class local_task {
template<typename S, typename F>
friend local_task<S, F> local_spawn(S& sched, F&& f);
template<typename F>
friend local_task<typename std::remove_reference<decltype(::async::default_scheduler())>::type, F> local_spawn(F&& f);
friend local_task<detail::default_scheduler_type, F> local_spawn(F&& f);

// Constructor, used by local_spawn
local_task(Sched& sched, Func&& f)
Expand Down Expand Up @@ -466,8 +466,11 @@ class local_task {

// Spawn a function asynchronously
template<typename Sched, typename Func>
task<typename detail::remove_task<decltype(std::declval<typename std::decay<Func>::type>()())>::type> spawn(Sched& sched, Func&& f)
task<typename detail::remove_task<typename std::result_of<typename std::decay<Func>::type()>::type>::type> spawn(Sched& sched, Func&& f)
{
// Using result_of in the function return type to work around bugs in the Intel
// C++ compiler.

// Make sure the function type is callable
typedef typename std::decay<Func>::type decay_func;
static_assert(detail::is_callable<decay_func()>::value, "Invalid function type passed to spawn()");
Expand Down Expand Up @@ -530,7 +533,7 @@ template<typename Func>
#ifdef __GNUC__
__attribute__((warn_unused_result))
#endif
local_task<typename std::remove_reference<decltype(::async::default_scheduler())>::type, Func> local_spawn(Func&& f)
local_task<detail::default_scheduler_type, Func> local_spawn(Func&& f)
{
return {::async::default_scheduler(), std::forward<Func>(f)};
}
Expand Down

0 comments on commit 4613fa0

Please sign in to comment.