Skip to content

Add design spec for C++17 migration#96

Open
joshbainbridge wants to merge 1 commit intomainfrom
cpp-17-migration
Open

Add design spec for C++17 migration#96
joshbainbridge wants to merge 1 commit intomainfrom
cpp-17-migration

Conversation

@joshbainbridge
Copy link
Copy Markdown
Collaborator

@joshbainbridge joshbainbridge commented Apr 25, 2026

The project currently requires a binary/header-only install split due to C++14 lacking inline variables. This causes user-facing complexity with three extra CMake options and conditional compilation in bntables.h. #86

Add a design document covering the migration plan from C++14 to C++17. This includes replacing constexpr/extern table patterns with inline constexpr, removing the OPENQMC_ENABLE_BINARY build machinery, and updating documentation.

For easier reading, you can enable the formatted display using this option on the Files changed tab:
image

The project currently requires a binary/header-only install split due to
C++14 lacking inline variables. This causes user-facing complexity with
three extra CMake options and conditional compilation in bntables.h.

Add a design document covering the migration plan from C++14 to C++17.
This includes replacing constexpr/extern table patterns with inline
constexpr, removing the OPENQMC_ENABLE_BINARY build machinery, updating
documentation, and assessing NVCC compatibility risks.

Assisted-by: Amp:claude-opus-4.6

Signed-off-by: Josh Bainbridge <josh.bainbridge@gmail.com>
C++17 introduces `inline` variable declarations. An `inline constexpr`
namespace-scope variable has external linkage and is guaranteed to have a
single definition across all translation units. This directly solves the
duplication problem with no build system workaround required.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Worth noting that OPENQMC_ENABLE_BINARY was solving two problems at once: C++14's internal-linkage duplication in the final binary, and having each TU parse ~393K lines of integer literals. C++17 inline constexpr fixes the duplication but reintroduces the per-TU parse cost. The spec should measure this on a representative consumer and accept the trade-off explicitly.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is great feedback. A really good point about the compiler time. I'll see if we can setup a test to verify the effect this change would have on this.

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.

Migrate project to C++17 standard and reduce complexity

2 participants