Skip to content

Commit 5fe9746

Browse files
authored
Merge pull request #5587 from reyoung/feature/fix_gpu_compile_on_linux
Fix GPU Compile on Linux
2 parents 29f494f + 1740502 commit 5fe9746

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

paddle/platform/call_once.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,22 @@ namespace platform {
2727
2828
This wrap is a hack to avoid this bug.
2929
*/
30-
template <class Callable, class... Args>
30+
template <typename Callable, typename... Args>
3131
inline void call_once(std::once_flag& flag, Callable&& f, Args&&... args) {
3232
bool good = false;
3333
std::exception ex;
34-
std::call_once(flag, [&]() {
35-
try {
36-
f(args...);
37-
good = true;
38-
} catch (const std::exception& e) {
39-
ex = e;
40-
} catch (...) {
41-
ex = std::runtime_error("excption caught in call_once");
42-
}
43-
});
34+
std::call_once(flag,
35+
[&](Args&&... args) {
36+
try {
37+
f(args...);
38+
good = true;
39+
} catch (const std::exception& e) {
40+
ex = e;
41+
} catch (...) {
42+
ex = std::runtime_error("excption caught in call_once");
43+
}
44+
},
45+
args...);
4446
if (!good) {
4547
throw std::exception(ex);
4648
}

0 commit comments

Comments
 (0)