From 36cd254bbd144a0f82abaccb02b88883ce3eca7a Mon Sep 17 00:00:00 2001 From: Stephan Hartmann Date: Tue, 8 Dec 2020 13:52:03 +0000 Subject: [PATCH] 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]' 76 | recorder->RecordIterable(str); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ Bug: None Change-Id: I535f5f5e0beded09f105f9871759b617c7384ae0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/35003 Reviewed-by: Corentin Wallez Commit-Queue: Stephan Hartmann --- src/dawn_native/ObjectContentHasher.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/dawn_native/ObjectContentHasher.h b/src/dawn_native/ObjectContentHasher.h index 2fed270149..88d8a54020 100644 --- a/src/dawn_native/ObjectContentHasher.h +++ b/src/dawn_native/ObjectContentHasher.h @@ -53,13 +53,6 @@ namespace dawn_native { } }; - template <> - struct RecordImpl { - static constexpr void Call(ObjectContentHasher* recorder, const std::string& str) { - recorder->RecordIterable(str); - } - }; - template struct RecordImpl> { static constexpr void Call(ObjectContentHasher* recorder, const std::vector& vec) { @@ -68,7 +61,7 @@ namespace dawn_native { }; template - 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 @@ namespace dawn_native { size_t mContentHash = 0; }; + + template <> + struct ObjectContentHasher::RecordImpl { + static constexpr void Call(ObjectContentHasher* recorder, const std::string& str) { + recorder->RecordIterable(str); + } + }; + } // namespace dawn_native #endif // DAWNNATIVE_OBJECT_CONTENT_HASHER_H_ \ No newline at end of file