Fix: patch bundled Boost hash.hpp for C++17 std::unary_function removal by Sahilll10 · Pull Request #2750 · su2code/SU2 · GitHub
Skip to content

Fix: patch bundled Boost hash.hpp for C++17 std::unary_function removal#2750

Merged
pcarruscag merged 2 commits into
su2code:developfrom
Sahilll10:fix/cpp17-boost-unary-function-tecio
Mar 10, 2026
Merged

Fix: patch bundled Boost hash.hpp for C++17 std::unary_function removal#2750
pcarruscag merged 2 commits into
su2code:developfrom
Sahilll10:fix/cpp17-boost-unary-function-tecio

Conversation

@Sahilll10

@Sahilll10 Sahilll10 commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

Root Cause

boost/container_hash/hash.hpp has 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_base inherits from std::unary_function which was
removed in C++17, causing a build failure.

Fix

Patched the #else branch of hash_base in externals/tecio/boost.tar.gz
to use explicit typedef declarations instead of std::unary_function
inheritance. This matches what the #if branch already does correctly for
MSVC. No behaviour change.

Verification

Zero occurrences of unary_function remain in
boost/container_hash/hash.hpp after repacking.

Files Changed

  • externals/tecio/boost.tar.gz — one struct patched in boost/container_hash/hash.hpp

PR 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

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
@joshkellyjak

joshkellyjak commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

@Sahilll10

Copy link
Copy Markdown
Contributor Author

Thanks for the review @joshkellyjakcom
I've also merged the latest develop into this branch to resolve any conflicts before review. The only file touched remains externals/tecio/boost.tar.gz — one struct patched, nothing else.

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 pcarruscag left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@joshkellyjak

joshkellyjak commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

@pcarruscag pcarruscag merged commit 4ed9f11 into su2code:develop Mar 10, 2026
36 of 37 checks passed
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.

3 participants