summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Natalie <jenatali@microsoft.com>2020-11-18 18:32:27 -0800
committerJesse Natalie <jenatali@microsoft.com>2020-12-02 10:13:33 -0800
commit149a036825ba74f9edd2468430f99ec0e927b845 (patch)
treee08a45da4a1f5ea987c2d3207f9ae0b10ccc1f4f
parent80817b6e344258ac9b955f824ebf9019a0fc1610 (diff)
clover: Fix property_element::as for MSVC
MSVC doesn't like reinterpret_cast<T>(val) where neither T nor val are pointers. It needs to be a static cast instead. v2: Update assert to static_assert Reviewed-by: Francisco Jerez <currojerez@riseup.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7680>
-rw-r--r--src/gallium/frontends/clover/core/property.hpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gallium/frontends/clover/core/property.hpp b/src/gallium/frontends/clover/core/property.hpp
index 7f8e17684d9..518f10dcaf9 100644
--- a/src/gallium/frontends/clover/core/property.hpp
+++ b/src/gallium/frontends/clover/core/property.hpp
@@ -199,12 +199,18 @@ namespace clover {
}
template<typename S>
- S
+ typename std::enable_if<!std::is_convertible<T, S>::value, S>::type
as() const {
- assert(sizeof(S) <= sizeof(T));
+ static_assert(sizeof(S) <= sizeof(T), "Ensure type fits in property list");
return reinterpret_cast<S>(x);
}
+ template<typename S>
+ typename std::enable_if<std::is_convertible<T, S>::value, S>::type
+ as() const {
+ return static_cast<S>(x);
+ }
+
private:
T x;
};