library: C++23 — deducing this for some recursive lambdas#229
Merged
Conversation
2aa2118 to
fe7a598
Compare
14a94f0 to
a12b59b
Compare
…us dnc; generalize NOLINT strip in update_main
b4d9c10 to
ce89ffc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Converts the library to C++23. Companion to #228 (infra/tests std bump), which this PR is stacked on — it must merge after #228, since the code here needs
-std=c++23to compile.Deducing
thisfor recursive lambdas (15 lambdas, 12 files)Recursive lambdas in
library/converted from the pass-self-explicitly idiom:Justification (correct/efficient/readable):
Converted files: trees/{centroid_decomp ×2, edge_cd ×2, shallowest_decomp_tree, uncommon/subtree_isomorphism}, graphs/{bcc_callback, euler_path, scc, uncommon/{bridges, cuts}, strongly_connected_components/{offline_incremental_scc, add_edges_strongly_connected}}, convolution/min_plus_convolution_convex_and_arbitrary.
Not converted (GCC bug): the 8 lambdas inside struct constructors — trees/{hld ×2, tree_lift, lca_rmq, linear_lca, uncommon/{hagerup_kth_par, ladder_decomposition, linear_kth_par}} — access data members through the captured
this. GCC 14/15 rejects member access inside a deducing-this lambda that captures the enclosingthis(GCC PR113563, fixed in GCC 16). CI's g++-14 (same as the Kattis judge) fails on them, so they keep the pass-self idiom until the toolchain moves past the bug.library/contest/tester.sh:-std=c++20→-std=c++23The stress tester should compile with the same standard as the contest judge (SEUSA 2025 on Kattis:
g++-14 -std=gnu++23).Evaluated and rejected:
std::generatorforget_prime_factors.hppMeasured before deciding. Rewriting the factor loop as a
std::generator<int>coroutine:-Werror— GCC's own<generator>triggers-Wmismatched-new-deleteunder-O2 -Wall(known false positive, GCC PR109224, still open), which would fail compile_gcc CI and require a suppression for zero gainThe existing "loop header you complete with a body" idiom stays.
Validation
g++ -std=c++23 -O2 -Wall -Wextraclang-format --dry-run --Werrorpasses on all changed filesNAME(NAME, ...)self-passing call sites in the converted files