chore: modernize header-only code to C++17 and remove dead code#4104
Merged
Conversation
The header-only library already requires C++17 (CMake targets declare cxx_std_17), so this removes the pre-C++17 compatibility shims and triplicated boilerplate, and fixes a couple of correctness/perf issues. - utils.h: drop the hand-rolled `is_integral_v`/`is_signed_v`/`is_same_v`/ `void_t` shims in favor of the standard `std::is_*_v` / `std::void_t`. - LayoutBuilder.h: replace the ~350 lines of `BufferNBytesFunctor`/ `ToBuffersFunctor`/`ToBufferFunctor`/`ToCharBuffersFunctor`/`SetIdFunctor`/ `ClearFunctor` classes (triplicated across Record, Tuple, and Union "for C++11 compatibility") with generic lambdas passed to `visit_at`. `ContentsFormFunctor` is intentionally left untouched. - LayoutBuilder.h: remove dead state that is written but never read: `Union::last_valid_index_`, `IndexedOption::last_valid_` (inlined as a local in `extend_valid`), `Tuple::field_index_`, and the unused uninitialized `Empty::id_`; also drop the unused `index_sequence` locals in `Union::to_buffers`/`to_buffer`/`to_char_buffers`. - GrowableBuffer.h: drop the `const` qualifier on the `options_` member so that GrowableBuffer (and every LayoutBuilder containing one) is move- assignable again, and explicitly `= default` the move-assignment operator (the user-declared move constructor otherwise suppresses it). Use `std::make_unique` and drop a redundant `std::move` of a temporary. - GrowableBuffer.h: fix `append()` so panel growth compounds geometrically (size new panels from the current reserved capacity, not from `initial`), and make `extend()` copy each contiguous segment with a `memcpy` when the type is trivially copyable. Behavior (lengths, contents) is unchanged; new tests cover multi-panel growth, `extend()` across panel boundaries, and move assignment. The BitMasked class region is intentionally avoided to minimize conflicts with an in-flight bug-fix PR. Assisted-by: ClaudeCode:claude-fable-5
Remove the redundant extend-across-panels test (extend correctness is already covered by the existing test_extend, and geometric growth by test_append_multi_panel_growth) and drop a comment that merely restated the fill_panel_from implementation. Assisted-by: ClaudeCode:claude-opus-4-8
henryiii
force-pushed
the
henryiii/header-only-cpp17
branch
from
June 11, 2026 19:45
d24e948 to
b4d77db
Compare
ianna
enabled auto-merge (squash)
June 22, 2026 20:25
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.
🤖 AI text below 🤖
This is a cleanup PR for the standalone
header-only/C++ library (which already requires C++17). It is public API for downstream C++ users — no public signatures or behaviors are changed. Only files underheader-only/are touched.Changes
header-only/layout-builder/awkward/utils.h— drop the hand-rolledis_integral_v/is_signed_v/is_same_v/void_t"until we switch to C++17" shims and usestd::is_*_v/std::void_t.header-only/layout-builder/awkward/LayoutBuilder.hBufferNBytesFunctor/ToBuffersFunctor/ToBufferFunctor/ToCharBuffersFunctor/SetIdFunctor/ClearFunctorhelper classes — triplicated nearly verbatim acrossRecord,Tuple, andUnion"for C++11 compatibility" — with generic lambdas passed tovisit_at.ContentsFormFunctoris intentionally left untouched to avoid conflicting with an in-flight form-bug-fix PR.Union::last_valid_index_,IndexedOption::last_valid_(its only real use, inextend_valid, is now a local),Tuple::field_index_, and the unused/uninitializedEmpty::id_. Also drop the unusedindex_sequencelocals inUnion::to_buffers/to_buffer/to_char_buffers.BitMaskedclass region is intentionally left alone.header-only/growable-buffer/awkward/GrowableBuffer.hconstqualifier on theoptions_member so thatGrowableBuffer(and everyLayoutBuilderthat contains one) is move-assignable again, and explicitly= defaultthe move-assignment operator (the existing user-declared move constructor otherwise suppresses it). Theoptions()accessor staysconst.std::make_uniqueinstead ofunique_ptr(new ...)and drop a redundantstd::moveof a temporary.append()so panel growth compounds geometrically: new panels are sized from the current reserved capacity (ceil(reserved * resize)) instead of alwaysceil(initial * resize)— previously, with default options, every panel was the sameinitial-sized 1024 elements, producing N/1024 linked panels.extend()now copies each contiguous segment with amemcpywhen the element type is trivially copyable (thePRIMITIVEhere always is) instead of element-by-element. Lengths and contents are identical.header-only/tests/test_1542-growable-buffer.cpp— add two focused tests for the behavior-affecting changes: multi-panel geometric growth viaappend(), and move assignment (which previously failed to compile because of theconstmember).extend()correctness across panel boundaries remains covered by the existingtest_extend.Testing
cmake -S header-only -B build -DBUILD_TESTS=ON && cmake --build buildbuilds cleanly. The growable-buffer, builder-options, and layout-builder-is-valid test executables pass, including the new tests.AI assistance
This PR was prepared with Claude Code as part of an automated review of the header-only library. Changes were verified by building and running the test suite.
Merge order
Two other in-flight PRs touch
GrowableBuffer.h(panel-copy/concatenate-offset bug fix) and theBitMaskedclass, so textual conflicts are expected at merge time. This PR should be rebased and merged afterhenryiii/fix-bitmasked-growablebufferandhenryiii/fix-layoutbuilder-form.🤖 Generated with Claude Code