Move Contains() helper function to a higher common.h. (#11289)

This commit is contained in:
Edward Chen 2022-04-21 09:31:48 -07:00 committed by GitHub
parent 7aa4af238a
commit 4d0214f851
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -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 Key, typename... OtherContainerArgs,
template <typename...> typename AssociativeContainer>
inline bool Contains(const AssociativeContainer<Key, OtherContainerArgs...>& container, const Key& key) {
return container.find(key) != container.end();
}
} // namespace onnxruntime

View file

@ -137,11 +137,6 @@ inline Status ComputePadAndOutputShape(const int64_t in_dim,
return Status::OK();
}
template <class AssociativeContainer, class Key>
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 <template <typename...> class Container, typename T>
T Product(const Container<T>& c) {