Skip to content

fix: avoid dangling-reference in sample tuple conversion for C++23 compatibility#423

Open
henryiii wants to merge 1 commit intoboostorg:developfrom
henryiii:fix/c++23-sample-tuple-conversion
Open

fix: avoid dangling-reference in sample tuple conversion for C++23 compatibility#423
henryiii wants to merge 1 commit intoboostorg:developfrom
henryiii:fix/c++23-sample-tuple-conversion

Conversation

@henryiii
Copy link
Copy Markdown
Contributor

Possible alternative fix for #420.

🤖 Assisted-by: OpenCode:Kimi-K2.6

…mpatibility

Under C++23 P2255R2 (Type Traits To Detect References Binding To
Temporaries), std::tuple's converting constructor is deleted when a
reference element would bind to a temporary. This broke code that
converts tuple<int> to tuple<const double&>, since the int is
first converted to a temporary double.

Fix: strip cv-qualifiers and reference from the deduced sample
argument types in accumulator_traits. This makes
accumulator_traits<mean<double>>::args == tuple<double> instead of
tuple<const double&>, so the compile-time convertibility check
is_convertible<tuple<int>, tuple<double>> succeeds.

Runtime behavior is unchanged; accumulators still receive arguments
through their const double& parameter.

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
Assisted-by: OpenCode:Kimi-K2.6
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.

1 participant