From 9f7d2454463e19f585f3acd75e2ca5b128a88a55 Mon Sep 17 00:00:00 2001 From: edgchen1 <18449977+edgchen1@users.noreply.github.com> Date: Wed, 27 May 2020 18:03:58 -0700 Subject: [PATCH] Add noexcept to various OrtCallback utility class methods to fix warnings. (#4056) --- onnxruntime/core/framework/callback.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/onnxruntime/core/framework/callback.h b/onnxruntime/core/framework/callback.h index 39e3908af5..88f14d7a5a 100644 --- a/onnxruntime/core/framework/callback.h +++ b/onnxruntime/core/framework/callback.h @@ -19,16 +19,16 @@ void OrtRunCallback(OrtCallback* f) noexcept; * Useful for something like a std::unique_ptr<> deleter. */ struct OrtCallbackInvoker { - OrtCallbackInvoker() + OrtCallbackInvoker() noexcept : callback{nullptr, nullptr} {} - OrtCallbackInvoker(OrtCallback callback_to_invoke) + OrtCallbackInvoker(OrtCallback callback_to_invoke) noexcept : callback(callback_to_invoke) {} OrtCallback callback; template - void operator()(T) { + void operator()(T) noexcept { if (callback.f) { callback.f(callback.param); } @@ -40,16 +40,16 @@ struct OrtCallbackInvoker { */ class ScopedOrtCallbackInvoker { public: - explicit ScopedOrtCallbackInvoker(OrtCallback callback) + explicit ScopedOrtCallbackInvoker(OrtCallback callback) noexcept : callback_(callback) {} - ScopedOrtCallbackInvoker(ScopedOrtCallbackInvoker&& other) + ScopedOrtCallbackInvoker(ScopedOrtCallbackInvoker&& other) noexcept : callback_(other.callback_) { other.callback_.f = nullptr; other.callback_.param = nullptr; } - ScopedOrtCallbackInvoker& operator=(ScopedOrtCallbackInvoker&& other) { + ScopedOrtCallbackInvoker& operator=(ScopedOrtCallbackInvoker&& other) noexcept { if (callback_.f) { callback_.f(callback_.param); } @@ -61,7 +61,7 @@ class ScopedOrtCallbackInvoker { return *this; } - ~ScopedOrtCallbackInvoker() { + ~ScopedOrtCallbackInvoker() noexcept { if (callback_.f) { callback_.f(callback_.param); }