<font size=2 face="sans-serif">The OpenMP specification has the following
restriction:</font><br><br><font size=2 face="sans-serif">"Variadic parameter packs cannot
be expanded into a directive or its clauses except as part of an expression
argument to be evaluated by the base language, such as into a function
call inside an if clause."</font><br><br><font size=2 face="sans-serif">The language committee has some discussions
on it in the last face-to-face meeting. We will look into relaxing
this restriction to provide better usage with C++ templates.<br><br>Kelvin<br></font><br><br><tt><font size=2>"Openmp-dev" <openmp-dev-bounces@lists.llvm.org>
wrote on 2018/10/15 10:45:30 AM:<br><br>> From: David Greene via Openmp-dev <openmp-dev@lists.llvm.org></font></tt><br><tt><font size=2>> To: "cfe-dev@lists.llvm.org" <cfe-dev@lists.llvm.org>,
"openmp-<br>> dev@lists.llvm.org" <openmp-dev@lists.llvm.org></font></tt><br><tt><font size=2>> Date: 2018/10/15 10:46 AM</font></tt><br><tt><font size=2>> Subject: [Openmp-dev] [OpenMP] Parameter packs</font></tt><br><tt><font size=2>> Sent by: "Openmp-dev" <openmp-dev-bounces@lists.llvm.org></font></tt><br><tt><font size=2>> <br>> Should this compile?<br>> <br>> #include <tuple><br>> <br>> constexpr std::size_t N = 100;<br>> <br>> double A[N];<br>> <br>> template<typename ...Args><br>> void loop(Args ...args) {<br>> #pragma omp parallel firstprivate(args...)<br>> for (std::size_t i = 0; i < N; ++i) {<br>> A[i] = (i + ... + args);<br>> }<br>> }<br>> <br>> int main(void) {<br>> std::apply([] (const auto & ...args) { loop(args...); },<br>> std::tuple<int,
double, float>(10, 2.6, 3.4));<br>> std::apply([] (const auto & ...args) { loop(args...); },<br>> std::tuple<int,
long, char, double, short>(10, 100,<br>> 'b', 2.6, 3));<br>> return 0;<br>> }<br>> <br>> clang++ errors with:<br>> <br>> firstprivate.cpp:10:39: error: expected ',' or ')' in 'firstprivate'
clause<br>> #pragma omp parallel firstprivate(args...)<br>>
^<br>> firstprivate.cpp:10:39: error: expected expression<br>> 2 errors generated.<br>> <br>> g++ gives a similar error. I was not terribly surprised by this.<br>> However, it sure would be nice if it worked.<br>> <br>>
-David<br>> _______________________________________________<br>> Openmp-dev mailing list<br>> Openmp-dev@lists.llvm.org<br>> </font></tt><a href=https://urldefense.proofpoint.com/v2/url?><tt><font size=2>https://urldefense.proofpoint.com/v2/url?</font></tt></a><tt><font size=2><br>> u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_openmp-2Ddev&d=DwIGaQ&c=jf_iaSHvJObTbx-<br>> siA1ZOg&r=yebGUrvFJWJ7GtM9woczVA&m=2EY3U33AkbJ5xLUmwJHWUGdi3b2YZ6eYCasI_AnITmo&s=5ovzADp3MTFkziuO0pgVRB4f6eqcyYS8Rujz1vEheF0&e=<br>> <br></font></tt><BR>