Fix: patch bundled Boost hash.hpp for C++17 std::unary_function removal - #2750
Conversation
In C++17, std::unary_function was removed. The bundled Boost headers in tecio (boost/container_hash/hash.hpp) use std::unary_function in hash_base under a guard (_HAS_AUTO_PTR_ETC) that only activates on MSVC. On MacOS clang and Linux GCC with C++17, the guard never triggers, causing a compilation error. Fix: replaced std::unary_function inheritance in the #else branch with explicit typedef declarations, identical to what the #if branch already does correctly. Fixes su2code#2583
|
Actually, I changed my mind, if this is fully deprecated in C++ 17 then the changes are probably better in the long run. LGTM |
|
Thanks for the review @joshkellyjakcom I believe this is ready — the fix is minimal, targeted, and consistent with how the #if branch already handles this. But I want to make sure I'm not missing anything before this gets merged. Let me know if there's anything else needed to get this across the line? I want to make sure this meets the project's standards. |
pcarruscag
left a comment
There was a problem hiding this comment.
I'm afraid I can't accept an opaque change to a binary file from a first-time contributor.
If there is no other way to apply the patch, I'll wait for Josh to look at the changes thoroughly.
Hi Pedro, I have looked through the changes, these are the only differences between the two versions of boost as from this branch and from current develop. These two are functionally equivalent and so, in my opinion, this is good to go, assuming the reg tests complete.
EDIT: Formatting |
Root Cause
boost/container_hash/hash.hpphas a guard#if defined(_HAS_AUTO_PTR_ETC)which is MSVC-only. On MacOS/clang and GCC with C++17, this guard never
activates, so
hash_baseinherits fromstd::unary_functionwhich wasremoved in C++17, causing a build failure.
Fix
Patched the
#elsebranch ofhash_baseinexternals/tecio/boost.tar.gzto use explicit
typedefdeclarations instead ofstd::unary_functioninheritance. This matches what the
#ifbranch already does correctly forMSVC. No behaviour change.
Verification
Zero occurrences of
unary_functionremain inboost/container_hash/hash.hppafter repacking.Files Changed
externals/tecio/boost.tar.gz— one struct patched inboost/container_hash/hash.hppPR Checklist
[ * ] I am submitting my contribution to the develop branch.
[ * ] My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
[ * ] My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
[ ] I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
[ ] I have added a test case that demonstrates my contribution, if necessary.
[ ] I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.
Fixes #2583