0

Im using Ubuntu 19.01 with g++9.1 to test the parallel new algorithms from the c++17.

I've already tested sucessfully with the algorithms std::sort and the std::reduce.

To compile i use:

g++-9.1 -std=c++17 -Wall -Wextra -pedantic t0.cpp -o t0 -ltbb

When i try to complipe the code it always appears this error:

erro: no matching function for call to ‘exclusive_scan(std::vector<int, std::allocator<int> >::iterator, std::vector<int, std::allocator<int> >::iterator, std::ostream_iterator<int>, int)’

What could be?

#include <functional>
#include <iostream>
#include <iterator>
#include <numeric>
#include <vector>
#include <algorithm>


int main()
{
  std::vector data {3, 1, 4, 1, 5, 9, 2, 6};

  std::cout << "exclusive sum: ";
  std::exclusive_scan(data.begin(), data.end(),
              std::ostream_iterator<int>(std::cout, " "),
              0);
  std::cout << "\ninclusive sum: ";
  std::inclusive_scan(data.begin(), data.end(),
              std::ostream_iterator<int>(std::cout, " "));

  std::cout << "\n\nexclusive product: ";  
  std::exclusive_scan(data.begin(), data.end(),
              std::ostream_iterator<int>(std::cout, " "),
              1, std::multiplies<>{});            
  std::cout << "\ninclusive product: ";
  std::inclusive_scan(data.begin(), data.end(),
              std::ostream_iterator<int>(std::cout, " "),
              std::multiplies<>{});           
}
f0g2345
  • 1
  • 3
  • 3
    Please include the command-line you used, as well as `g++ --version` – Yakk - Adam Nevraumont Sep 10 '19 at 17:55
  • Related: [g++ with std::exclusive_scan (c++17)](https://stackoverflow.com/q/55771604/580083). Note this comment: [Interestingly, gcc-9 seems to have the parallel version but not the sequential one...](https://stackoverflow.com/questions/55771604/g-with-stdexclusive-scan-c17#comment98216497_55771604). – Daniel Langr Sep 10 '19 at 18:04

0 Answers0