The global function has issues:
- It causes gcc-13 warnings, see #26926
- There is no rationale for it being a global function, when it acts like a member function
performance-unnecessary-copy-initialization
clang-tidy isn’t run on it
Fix all issues by making it a member function.