I am trying to get this snippet to compile
#include <vector>
#include <numeric>
#include <execution>
double result = std::reduce(std::execution::par, v.begin(), v.end());
I tried these compilers:
Apple LLVM version 8.1.0 (clang-802.0.42)
clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
All three give me 'execution' file not found
respectively error: no member named 'reduce' in namespace 'std'
auto result = std::reduce(v.begin(), v.end());
for this snippet
#include<numeric>
#include<vector>
int main(int argc, char *argv[])
{
std::vector<double> v(10, 1);
auto result = std::reduce(v.begin(), v.end());
return 0;
}
I guess my compilers are too old? But on cppreference it does not say which compiler version is requiered minimum and also I do not see any newer versions for clang or gcc in the repo.
std::reduce
and std::execution::par
are available since C++17.
For most of the compilers C++17 isn't fully implemented yet. You can try using clang with flag -std=c++1z
.
I upgraded my GCC to version 10 and it compiled fine the std::execution::par
with its include <execution>
(which was failing to locate with gcc version 7.5.0). I followed to the instructions in this link: https://tuxamito.com/wiki/index.php/Installing_newer_GCC_versions_in_Ubuntu
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With