Skip to content

Common: add MoveOnlyFunction for move-only callbacks - #1810

Merged
Mysticial merged 1 commit into
PokemonAutomation:mainfrom
dayfine:upstream/move-only-function
Nov 1, 2026
Merged

Mysticial merged 1 commit into
PokemonAutomation:mainfrom
dayfine:upstream/move-only-function

Conversation

@dayfine

@dayfine dayfine commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Base: main; independent, single commit.

Adds MoveOnlyFunction for callbacks with one owner and move-only captures. Uses std::move_only_function where available, with a small fallback for Apple libc++. Existing callbacks are unchanged.

Four unit tests cover move-only captures, state across moves, empty/null callables, and reassignment. Build/tests passed on Mac, Windows Clang, and Ubuntu at 95e3e6479.

The fork's code-health check flags the fallback's internal type-erasure interface as a single-method interface; that finding remains unresolved.

Prepared with Claude Code and Codex. Fork review: dayfine#72.

@dayfine
dayfine marked this pull request as ready for review November 1, 2026 05:04
std::function is copyable: copying one silently forks a stateful lambda's
state, and it can't hold move-only captures. std::move_only_function (C++23)
fixes both, but Apple Clang's libc++ doesn't implement it yet.
MoveOnlyFunction is an alias of std::move_only_function where the library
provides it, and a small fallback elsewhere, with copying deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
@dayfine
dayfine force-pushed the upstream/move-only-function branch from 95e3e64 to bda38f7 Compare November 1, 2026 05:08
@Mysticial
Mysticial merged commit b3673f2 into PokemonAutomation:main Nov 1, 2026
7 checks passed
dayfine added a commit to dayfine/Arduino-Source that referenced this pull request Nov 1, 2026
dayfine added a commit to dayfine/Arduino-Source that referenced this pull request Nov 1, 2026
Upstream merged MoveOnlyFunction as PokemonAutomation#1810,
so this branch's copy is redundant: MoveOnlyFunction_Tests.cpp takes
upstream's version, the header and test list were already identical.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
dayfine added a commit to dayfine/Arduino-Source that referenced this pull request Nov 2, 2026
Upstream merged MoveOnlyFunction as PokemonAutomation#1810.
Conflicts in MoveOnlyFunction_Tests.cpp, ComputerPrograms_UnitTestRunner.cpp
and SourceFiles.cmake take main's (PokemonAutomation#1810's) versions; this branch's
migration of the thread pool and its callers is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E
@dayfine
dayfine deleted the upstream/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.

2 participants