From d3ddf050a5f1cbcd1510695eeee688472911d6a2 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Sun, 30 Jul 2017 16:07:01 -0700 Subject: [PATCH] Correct specialization of throw_on_error for pointer types --- paddle/platform/enforce.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/paddle/platform/enforce.h b/paddle/platform/enforce.h index ab474508d98..89a948e495e 100644 --- a/paddle/platform/enforce.h +++ b/paddle/platform/enforce.h @@ -127,9 +127,15 @@ inline typename std::enable_if::type throw_on_error( #endif // PADDLE_ONLY_CPU -template -inline void throw_on_error(T* e) { - throw_on_error(e != nullptr, ""); +template +inline typename std::enable_if::value, void>::type +throw_on_error(T stat, const Args&... args) { + if (stat == nullptr) { + return; + } else { + throw std::runtime_error("Pointer value is nullptr: " + + string::Sprintf(args...)); + } } template -- GitLab