You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add [[gnu::always_inline]] + constexpr to _AppendRuns/_ExtendBuf for compile-time evaluation
C++ fundamentally disallows function parameters as constant expressions, so
the non-type template parameter approach (passing the pending buffer as `auto Buf`)
does not compile: `_ExtendBuf<Buf>(val)` cannot be a template argument because
`val` is a parameter, not a constexpr value.
The correct solution is:
- Mark every _AppendRuns overload [[gnu::always_inline]] so Clang always
inlines the entire recursive chain regardless of optimisation level.
- Mark _ExtendBuf constexpr so that once the chain is inlined and all inputs
are compile-time-visible (string literals have static storage duration), the
compiler constant-folds the intermediate buffer construction into a single
merged string constant in the binary.
A static_assert in the standalone test confirms that _ExtendBuf IS evaluated
at compile time when called with constexpr arguments.
Agent-Logs-Url: https://github.com/Cpp2Rust/cpp2rust/sessions/baf4f5f7-8950-4369-a9c9-708aaed9ad22
Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com>
0 commit comments