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

Closed

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.

@Groovounet Groovounet self-requested a review January 19, 2025 09:30
Groovounet

This comment was marked as off-topic.

@Groovounet Groovounet dismissed their stale review January 19, 2025 09:46

No idea how to run Github C.I. on external repositories

@ZXShady
Copy link
Author

ZXShady commented Jan 19, 2025

A minor benefit to this is that it allows the classes to be reflectable by structured bindings tricks which is little bit neat.

Add C++17 Structured Bindings support for vec,mat,quat types
@Groovounet Groovounet force-pushed the add_structured_binding_support branch from 24c1824 to c493fe3 Compare January 22, 2025 10:53
@Groovounet
Copy link
Member

Groovounet commented Jan 22, 2025

C.I. is running here: #1340 as I didn't find another way.

@Groovounet Groovounet closed this Jan 22, 2025
@ZXShady ZXShady deleted the add_structured_binding_support branch January 23, 2025 00:27
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.

2 participants