Skip to content

Commit ef75946

Browse files
author
Darryl Gough
authored
Fix failed assert in XrMath.h (#110)
Fixed issue #109. The error occurred in VS2022 but not in the VS2019 toolset. The compiler error message isn't as obvious now but I added a comment if anyone tries to use xr::math::cast for a type that hasn't added a template specialization.
1 parent e1a3b69 commit ef75946

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

shared/XrUtility/XrMath.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ namespace xr::math {
5353
NearFar NearFar;
5454
};
5555

56-
// Type conversion between math types
56+
// Type conversion between math types.
57+
// If you get the error "attempting to reference a deleted function" then you need to implement
58+
// xr::math::detail::implement_math_cast for types X and Y. See examples further down.
5759
template <typename X, typename Y>
58-
constexpr const X& cast(const Y& value);
60+
constexpr const X& cast(const Y& value) = delete;
5961

6062
// Convert XR types to DX
6163
DirectX::XMVECTOR XM_CALLCONV LoadXrVector2(const XrVector2f& vector);
@@ -105,13 +107,6 @@ namespace xr::math {
105107
}
106108
} // namespace detail
107109

108-
#ifdef _MSC_VER
109-
template <typename X, typename Y>
110-
constexpr const X& cast(const Y& value) {
111-
static_assert(false, "Undefined cast from Y to type X");
112-
}
113-
#endif
114-
115110
#define DEFINE_CAST(X, Y) \
116111
template <> \
117112
constexpr const X& cast<X, Y>(const Y& value) { \

0 commit comments

Comments
 (0)