On 2 June 2013 19:01, Oliver Kullmann <O.Kullmann@xxxxxxxxxxxxx> wrote: > Hello, > > I can compile > > --- > > #include <iostream> > #include <vector> > #include <numeric> > #include <future> > > template <typename RAIter> > int parallel_sum(const RAIter beg, const RAIter end) { > const auto len = end-beg; > if(len < 1000) return std::accumulate(beg, end, 0); > > const RAIter mid = beg + len/2; > auto handle = std::async(std::launch::async, parallel_sum<RAIter>, mid, end); > const int sum = parallel_sum(beg, mid); > return sum + handle.get(); > } > > int main() { > std::vector<int> v(10000, 1); > std::cout << "The sum is " << parallel_sum(v.begin(), v.end()) << ".\n"; > } > > --- > > using "g++ -Wall -std=c++11", but running it I get > > terminate called after throwing an instance of 'std::system_error' > what(): Unknown error -1 > Aborted (core dumped) You need to compile and link using -pthread to make use of multithreading.