[cfe-dev] [OpenMP] Parameter packs

David Greene via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 15 07:45:30 PDT 2018


Should this compile?

#include <tuple>

constexpr std::size_t N = 100;

double A[N];

template<typename ...Args>
void loop(Args ...args) {
#pragma omp parallel firstprivate(args...)
  for (std::size_t i = 0; i < N; ++i) {
    A[i] = (i + ... + args);
  }
}

int main(void) {
  std::apply([] (const auto & ...args) { loop(args...); },
                 std::tuple<int, double, float>(10, 2.6, 3.4));
  std::apply([] (const auto & ...args) { loop(args...); },
                 std::tuple<int, long, char, double, short>(10, 100, 'b', 2.6, 3));
  return 0;
}

clang++ errors with:

firstprivate.cpp:10:39: error: expected ',' or ')' in 'firstprivate' clause
#pragma omp parallel firstprivate(args...)
                                      ^
firstprivate.cpp:10:39: error: expected expression
2 errors generated.

g++ gives a similar error.  I was not terribly surprised by this.
However, it sure would be nice if it worked.

                      -David



More information about the cfe-dev mailing list