From 174050277aa78ea4d2871c67f72c2307c3ac2120 Mon Sep 17 00:00:00 2001 From: Yang Yu Date: Mon, 13 Nov 2017 13:56:41 +0800 Subject: [PATCH] Fix GPU Compile on Linux --- paddle/platform/call_once.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/paddle/platform/call_once.h b/paddle/platform/call_once.h index 248baf6613c..d9f49527dcf 100644 --- a/paddle/platform/call_once.h +++ b/paddle/platform/call_once.h @@ -27,20 +27,22 @@ namespace platform { This wrap is a hack to avoid this bug. */ -template +template inline void call_once(std::once_flag& flag, Callable&& f, Args&&... args) { bool good = false; std::exception ex; - std::call_once(flag, [&]() { - try { - f(args...); - good = true; - } catch (const std::exception& e) { - ex = e; - } catch (...) { - ex = std::runtime_error("excption caught in call_once"); - } - }); + std::call_once(flag, + [&](Args&&... args) { + try { + f(args...); + good = true; + } catch (const std::exception& e) { + ex = e; + } catch (...) { + ex = std::runtime_error("excption caught in call_once"); + } + }, + args...); if (!good) { throw std::exception(ex); } -- GitLab