Skip to content
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

Add C++17 Structured Bindings Support for r,g,b,a and s,t,p,q Member Vectors and Mat and Quat #1320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ZXShady
Copy link

@ZXShady ZXShady commented Nov 10, 2024

This PR introduces structured bindings support for improved readability and allows for more concise code
Key Changes:
- You are now allowed to use structured bindings even when GLM_FORCE_MEMBERS_XYZW macro is not defined fixing an inconsistency.
- You can use structured bindings on mat and qua types

// Before
auto w  = obj.getSize().x; 
auto h = obj.getSize().y; // calls getSize again.

// After
auto [w, h] = obj.getSize();
glm::vec3 v;
auto [x,y,z] = v; // used to be an error unless GLM_FORCE_MEMBERS_XYZW was defined

Structured bindings make the code more readable, especially when accessing multiple members of an temporary from a function call. It reduces verbosity.

Add C++17 Structured Bindings support for vec,mat,quat types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant