Skip to content

Fix sstream_convert for types not constructible from const char*#418

Merged
evaleev merged 1 commit into
evaleev:masterfrom
susilehtola:fix/sstream-convert-double
May 20, 2026
Merged

Fix sstream_convert for types not constructible from const char*#418
evaleev merged 1 commit into
evaleev:masterfrom
susilehtola:fix/sstream-convert-double

Conversation

@susilehtola
Copy link
Copy Markdown
Contributor

Summary

  • sstream_convert<To> constructs the destination as To to(ss.str().c_str()), which only compiles when To accepts a const char* (e.g. mpf_class). Instantiations with To = double from tests/unit/test-core-ints.cc fail to compile under gcc 16.
  • Dispatch via SFINAE: keep the c_str() construction for types constructible from const char* (preserves the existing mpf_class precision-via-string path), and use stream extraction (To to; ss >> to;) for everything else (double, etc.).

Fixes #417

Test plan

  • unit_tests-libint2 builds with gcc 16 and LIBINT_HAS_MPFR=1
  • libint2/unit/run and libint2/unit/sho=gaussian/run ctest targets pass

🤖 Generated with Claude Code

The sstream_convert template constructed the destination type via
To to(ss.str().c_str()), which only works when To accepts a
const char* (e.g. mpf_class). Instantiations with To = double, used
in tests/unit/test-core-ints.cc, fail to compile under gcc 16.

Dispatch via SFINAE: keep the c_str() construction for types that
accept const char*, and use stream extraction (To to; ss >> to;) for
all others.

Fixes evaleev#417

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@evaleev evaleev merged commit 04a99b4 into evaleev:master May 20, 2026
10 checks passed
@susilehtola susilehtola deleted the fix/sstream-convert-double branch May 20, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests dont compile

2 participants