I hit an issue this week while working with parallel::for_each over
partitioned_vectors. parallel::for_each works well over std::vector types
but, when attempting to perform a parallel::for_each over
partitioned_vectors, gcc complains that the lambda function I'm supplying
isn't a structure with an overloaded operator().

The code below works well:

std::vector<int> vec(100);
int value = 100;

hpx::parallel::transform(
  hpx::parallel::execution::par,
  std::begin(vec),
  std::end(vec),
  std::begin(vec),
  [&value](int val) {
    return value;
  });

hpx::parallel::for_each(
  hpx::parallel::execution::par,
  std::begin(vec),
  std::end(vec),
  [](int val) {
    hpx::cout << val << hpx::endl;
  });

The code below fails to compile:

hpx::partitioned_vector<int> vec(100,
hpx::container_layout(hpx::find_all_localities()));
vec.register_as("intvectors");

int value = 100;

hpx::parallel::transform(
  hpx::parallel::execution::par,
  std::begin(vec),
  std::end(vec),
  std::begin(vec),
  [&value](int val) {
    return value;
  });

hpx::parallel::for_each(
  hpx::parallel::execution::par,
  std::begin(vec),
  std::end(vec),
  [](int val) {
    hpx::cout << val << hpx::endl;
  });

gcc throws a compiler error on the line where the for_each is supplied the
lambda. The error implies that parallel::for_each requires/expects a data
type similar to std::plus<int>() with an overloaded operator().

Did I make an error, find a new error, or is this an edge case?

V/r,

Chris
_______________________________________________
hpx-users mailing list
[email protected]
https://mail.cct.lsu.edu/mailman/listinfo/hpx-users

Reply via email to