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>
This commit is contained in:
parent
80817b6e34
commit
149a036825
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue