KhronosGroup / OpenXR-Tutorials

OpenXR Tutorials
https://www.openxr-tutorial.com/
Apache License 2.0
84 stars 15 forks source link

Nitpick: Use auto for XrEventDataBuffer reinterpret_cast #101

Closed pfontain closed 10 months ago

pfontain commented 10 months ago

In OpenXRTutorial::PollEvents() the assignments from reinterpret_cast of the XrEventDataBuffer can use auto. The reinterpret_cast already makes the type explicit.

XrEventDataEventsLost eventsLost = reinterpret_cast<XrEventDataEventsLost >(&eventData); -> auto eventsLost = reinterpret_cast<XrEventDataEventsLost *>(&eventData);

pfontain commented 10 months ago

Happy to create the merge request once I'm done with other changes.

AndrewRichards-Code commented 10 months ago

Hi @pfontain, We discussed how best to use auto in this project and we decided that we wanted to make the code as explicit as possible to best reflect the usage of any OpenXR types as in this case. Thank you for your feedback and pull requests.

pfontain commented 10 months ago

I agree that type deduction shouldn't be overused (I usually try to follow Google's C++ Style Guide https://google.github.io/styleguide/cppguide.html#Type_deduction) but I think in this specific case the reinterpret_cast already makes it explicit. It might be worth it to create a document in the repository, I didn't find one yet, concerning code style for contributions with some of these types of decisions. Thank you for the reply and maintaining the repository :)