-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding constexpr qualifier for helper functions #1050
Conversation
lessThan, lessThanEqual, greaterThan, greaterThanEqual
mix(scalar, scalar), mix(vec, vec, vec), mix(vec,vec,scalar)
Default ctor used in constexpr contex generates warning on gcc
I don't think that my code failed tests. |
Would you mind to rebase your commit to master branch that is fixed? |
Of course, I'll do it later. Have a nice holidays! |
lessThan, lessThanEqual, greaterThan, greaterThanEqual
mix(scalar, scalar), mix(vec, vec, vec), mix(vec,vec,scalar)
Default ctor used in constexpr contex generates warning on gcc
@@ -91,7 +91,7 @@ namespace detail | |||
template<length_t L, typename T, qualifier Q, bool Aligned> | |||
struct compute_mix_vector<L, T, bool, Q, Aligned> | |||
{ | |||
GLM_FUNC_QUALIFIER static vec<L, T, Q> call(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, bool, Q> const& a) | |||
GLM_FUNC_QUALIFIER GLM_CONSTEXPR static vec<L, T, Q> call(vec<L, T, Q> const& x, vec<L, T, Q> const& y, vec<L, bool, Q> const& a) | |||
{ | |||
vec<L, T, Q> Result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be failing the GCC6 C++14 builds in Travis. I think it's the C++14 vs C++17 discrepancy in what's allowed inside constexpr
functions. This StackOverflow issue sheds some extra light: https://stackoverflow.com/questions/41618576/what-is-allowed-in-a-constexpr-function
In this case, Result
should be initialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've seen it. My bad. I'll fix it this evening.
The only way to init the result variable is |
Hi, |
I created a new PR #1184 to run the unit tests Thanks for contributing! |
* Adding constexpr for exterior product * Adding constexpr for conjugate * Adding constexpr for dot, cross and inverse quaternion functions * Adding constexpr for quat lerp * Adding constexpr to quaternion comparison functions lessThan, lessThanEqual, greaterThan, greaterThanEqual * Adding constexpr for mix functions mix(scalar, scalar), mix(vec, vec, vec), mix(vec,vec,scalar) * Adding constexpr for sign(vec) and sign(genFIType) * Initialize result lessThan, lessThanEqual, greaterThan, greaterThanEqual Default ctor used in constexpr contex generates warning on gcc * Adding constexpr to cross(vec, qua) and cross(qua, vec) * Adding constexpr to glm::translate * Adding constexpr for exterior product * Adding constexpr for conjugate * Adding constexpr for dot, cross and inverse quaternion functions * Adding constexpr for quat lerp * Adding constexpr to quaternion comparison functions lessThan, lessThanEqual, greaterThan, greaterThanEqual * Adding constexpr for mix functions mix(scalar, scalar), mix(vec, vec, vec), mix(vec,vec,scalar) * Adding constexpr for sign(vec) and sign(genFIType) * Initialize result lessThan, lessThanEqual, greaterThan, greaterThanEqual Default ctor used in constexpr contex generates warning on gcc * Adding constexpr to cross(vec, qua) and cross(qua, vec) * Adding constexpr to glm::translate --------- Co-authored-by: RohacekD <[email protected]>
constexpr
qualifier forvec sign(vec)
functionconstexpr
qualifier formix(scalar, scalar, scalar)
,mix(vec, vec, scalar)
,mix(vec, vec, vec)
functionsconstexpr
qualifier format translate(mat, vec)
functionconstexpr
qualifier forqua lerp(qua, qua, scalar a)
functionconstexpr
qualifier forqua conjugate(qua)
functionconstexpr
qualifier forqua inverse(qua)
functionconstexpr
qualifier forscalar dot(qua, qua)
functionconstexpr
qualifier forqua cross(qua, qua)
functionconstexpr
qualifier forvec<bool> lessThan(qua, qua)
functionconstexpr
qualifier forvec<bool> lessThanEqual(qua, qua)
functionconstexpr
qualifier forvec<bool> greaterThan(qua, qua)
functionconstexpr
qualifier forvec<bool> greaterThanEqual(qua, qua)
functionconstexpr
qualifier forvec<bool> greaterThanEqual(qua, qua)
functionconstexpr
qualifier forexterior_product
functionconstexpr
qualifier forvec3 cross(qua, vec)
functionconstexpr
qualifier forvec3 cross(vec, qua)
functionI tried functions in constexpr context and had no errors. I had to do a small change in comparison functions to avoid warning about default constructed object by initialising results to
false
.False
values will be rewritten by following for cycles but GCC complained anyway.