Skip to content

Common: add MoveOnlyFunction, a move-only callable wrapper - #72

Closed
dayfine wants to merge 4 commits into
mainfrom
common/move-only-function
Closed

dayfine wants to merge 4 commits into
mainfrom
common/move-only-function

Conversation

@dayfine

@dayfine dayfine commented Oct 30, 2026

Copy link
Copy Markdown
Owner

std::function is copyable, so copying one silently forks a stateful lambda's state, and it can't hold move-only captures. std::move_only_function fixes both, but Apple Clang's libc++ doesn't have it yet. MoveOnlyFunction is an alias of std::move_only_function where the library defines it (GCC, MSVC) and a small fallback elsewhere (macOS), with copying deleted. Tested with four unit tests on fork CI (Mac runs the fallback; Ubuntu and Windows clang run the std branch); migrating existing std::function uses comes next in small per-module batches.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E

dayfine and others added 2 commits October 29, 2026 21:56
std::function is copyable: copying it forks a stateful lambda's state,
and it cannot hold move-only captures. MoveOnlyFunction is an alias of
std::move_only_function where the standard library has it, and a
minimal R(Args...) fallback for Apple's libc++, which lacks it.

Tests: move-only capture, moving keeps one state, empty and nullptr
comparison, reassignment; copy is rejected at compile time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
… tests

The standard does not make std::move_only_function's move assignment
noexcept, and MSVC's STL does not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine and others added 2 commits October 30, 2026 07:38
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine added a commit that referenced this pull request Nov 1, 2026
Both games plan on Grid and LegPlanner, so those stay here. The rest
served one game each and moves to its user: ScreenMachine/StepTrace to
common/screen-machine, LegWalker to frlg/brock-mvp (where LegMover is a
small abstract class, so MoveOnlyFunction is no longer needed here),
TileGrid and MapSet to bdsp/tilegrid-mapset. The MoveOnlyFunction copy
of #72 goes with them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine added a commit that referenced this pull request Nov 1, 2026
LegMover was an alias for a MoveOnlyFunction; a class with one virtual
hold() (as the BDSP copy has) needs no callable wrapper, so the walker
can leave the shared core and come along with FRLG without #72.
FRLG's D-pad mover becomes DpadMover.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine added a commit that referenced this pull request Nov 1, 2026
StoryEvents holds its observations and actions in MoveOnlyFunctions.
nav/core no longer includes the copy of #72, so it comes along here,
byte-identical to common/move-only-function, and goes when #72 merges.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
@dayfine

dayfine commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #114 (commit S1 823f531 of the shared-core collector). Branch kept.

@dayfine dayfine closed this Nov 1, 2026
@dayfine
dayfine deleted the common/move-only-function branch November 3, 2026 05:46
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