GCC: fix template specialization in ObjectContentHasher
GCC complains that explicit specialization in non-namespace scope
is happening for ObjectContentHasher.
In file included from
../../third_party/dawn/src/dawn_native/ShaderModule.cpp:19:
../../third_party/dawn/src/dawn_native/ObjectContentHasher.h:56:19:
error: explicit specialization in non-namespace scope 'class
dawn_native::ObjectContentHasher'
56 | template <>
| ^
Additionally make RecordIterable constexpr, because it is called
from constexpr methods. GCC complains about this as well:
../../third_party/dawn/src/dawn_native/ObjectContentHasher.h:76:50:
error: call to non-'constexpr' function 'void
dawn_native::ObjectContentHasher::RecordIterable(const IteratorT&) [with
IteratorT = std::__cxx11::basic_string<char>]'
76 | recorder->RecordIterable<std::string>(str);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
Bug: None
Change-Id: I535f5f5e0beded09f105f9871759b617c7384ae0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/35003
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Stephan Hartmann <stha09@googlemail.com>
diff --git a/src/dawn_native/ObjectContentHasher.h b/src/dawn_native/ObjectContentHasher.h
index 2fed2701..88d8a54 100644
--- a/src/dawn_native/ObjectContentHasher.h
+++ b/src/dawn_native/ObjectContentHasher.h
@@ -53,13 +53,6 @@
}
};
- template <>
- struct RecordImpl<std::string> {
- static constexpr void Call(ObjectContentHasher* recorder, const std::string& str) {
- recorder->RecordIterable<std::string>(str);
- }
- };
-
template <typename T>
struct RecordImpl<std::vector<T>> {
static constexpr void Call(ObjectContentHasher* recorder, const std::vector<T>& vec) {
@@ -68,7 +61,7 @@
};
template <typename IteratorT>
- void RecordIterable(const IteratorT& iterable) {
+ constexpr void RecordIterable(const IteratorT& iterable) {
for (auto it = iterable.begin(); it != iterable.end(); ++it) {
Record(*it);
}
@@ -76,6 +69,14 @@
size_t mContentHash = 0;
};
+
+ template <>
+ struct ObjectContentHasher::RecordImpl<std::string> {
+ static constexpr void Call(ObjectContentHasher* recorder, const std::string& str) {
+ recorder->RecordIterable<std::string>(str);
+ }
+ };
+
} // namespace dawn_native
#endif // DAWNNATIVE_OBJECT_CONTENT_HASHER_H_
\ No newline at end of file