I only see some possible stylistic/reusability improvements:
You use
decltype(std::declval<T>() + std::declval<T>())
five times in the function (I did not countplus the one in the return type). You could probablytypedef
that to improve readability. I don't know how you would call it, but I am pretty sure that you can find a meaningful name.By the way, are there many types for which
decltype(std::declval<T>() + std::declval<T>)
is different fromT
while still being amp compatible? If it is the case, that may break some other pieces of your code anyway (I didn't check though; that's a wild guess).Whenever possible, try to use
std::begin
andstd::end
instead of the member functions. It helps to write reusable code; you might someday want to extract parts of your function to write smaller and more generic functions that could work on old C arrays.By default, if you don't specify the rank of an
array_view
, it is one. Therefore, Iyou actually don't have to specify it since you always use 1.Your lines are really long. As I said in the comments, you might want to split some of them to improve readability:
futTailSum = std::async( std::launch::async, [&vecTail] { return concurrency::parallel_reduce( std::begin(vecTail), std::end(vecTail), static_cast<T>(0) ); } );