From 4d0214f8510c740682082a00b00a5f2422142165 Mon Sep 17 00:00:00 2001 From: Edward Chen <18449977+edgchen1@users.noreply.github.com> Date: Thu, 21 Apr 2022 09:31:48 -0700 Subject: [PATCH] Move Contains() helper function to a higher common.h. (#11289) --- include/onnxruntime/core/common/common.h | 8 ++++++++ onnxruntime/core/providers/common.h | 5 ----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/onnxruntime/core/common/common.h b/include/onnxruntime/core/common/common.h index 7b82bc0c3c..cf6d2138ca 100644 --- a/include/onnxruntime/core/common/common.h +++ b/include/onnxruntime/core/common/common.h @@ -286,4 +286,12 @@ inline std::string ToWideString(const std::string& s) { return s; } constexpr size_t kMaxStrLen = 2048; +// Returns whether `key` is in `container`. +// Like C++20's map/set contains() member function. +template typename AssociativeContainer> +inline bool Contains(const AssociativeContainer& container, const Key& key) { + return container.find(key) != container.end(); +} + } // namespace onnxruntime diff --git a/onnxruntime/core/providers/common.h b/onnxruntime/core/providers/common.h index 22949ed297..c821ff0650 100644 --- a/onnxruntime/core/providers/common.h +++ b/onnxruntime/core/providers/common.h @@ -137,11 +137,6 @@ inline Status ComputePadAndOutputShape(const int64_t in_dim, return Status::OK(); } -template -inline bool Contains(const AssociativeContainer& container, const Key& key) { - return container.find(key) != container.end(); -} - // Note: This helper function will not have overflow protection template