Skip to content

Mark template function in math_funcs_binary constexpr#118027

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
zhehangd:constexpr_math_funcs_binary
Mar 31, 2026
Merged

Mark template function in math_funcs_binary constexpr#118027
Repiteo merged 1 commit intogodotengine:masterfrom
zhehangd:constexpr_math_funcs_binary

Conversation

@zhehangd
Copy link
Copy Markdown
Contributor

In fixing a compile error of my gdextension I noticed the inconsistency of using inline, inline static, constexpr between godot-cpp(include/godot_cpp/core/defs.hpp) and godot (core/math/math_funcs_binary.h). The detail of my issue can be found below:
godotengine/godot-cpp#1962

godot uses constexpr for most of functions in that file except for the two template functions is_power_of_2 and nearest_power_of_2_templated which use just inline. godot-cpp uses static inline everywhere, and the static inline template function made my gdextension lib fail to build. Though I am not sure if it is a real error according to C++ standard or is just a clang bug with module, but I think static inline is not something appropriate in modern C++. So to be consistent I suggest that we put everything constexpr while possible. For the engine the only change is the two template functions.

@zhehangd zhehangd requested a review from a team as a code owner March 31, 2026 09:16
@Repiteo Repiteo modified the milestones: 4.x, 4.7 Mar 31, 2026
@Repiteo Repiteo merged commit 4a919ad into godotengine:master Mar 31, 2026
20 checks passed
@Repiteo
Copy link
Copy Markdown
Contributor

Repiteo commented Mar 31, 2026

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants