LockedPtr::transform implemented - #456
Open
sankurm wants to merge 1 commit into
Open
Conversation
sankurm
requested review from
4og,
antonkri,
arkjedrz,
fbaeuerle and
pawelrutkaq
as code owners
August 11, 2026 09:54
sankurm
requested a deployment
to
workflow-approval
August 11, 2026 09:54 — with
GitHub Actions
Waiting
sankurm
requested a deployment
to
workflow-approval
August 11, 2026 09:54 — with
GitHub Actions
Waiting
sankurm
requested a deployment
to
workflow-approval
August 11, 2026 09:54 — with
GitHub Actions
Waiting
sankurm
requested a deployment
to
workflow-approval
August 11, 2026 09:54 — with
GitHub Actions
Waiting
Contributor
|
The created documentation from the pull request is available at: docu-html |
sankurm
force-pushed
the
locked_ptr_monadic_transform
branch
from
August 11, 2026 11:00
612eded to
6c94c7c
Compare
sankurm
temporarily deployed
to
workflow-approval
August 11, 2026 11:00 — with
GitHub Actions
Inactive
sankurm
temporarily deployed
to
workflow-approval
August 11, 2026 11:00 — with
GitHub Actions
Inactive
sankurm
temporarily deployed
to
workflow-approval
August 11, 2026 11:00 — with
GitHub Actions
Inactive
sankurm
temporarily deployed
to
workflow-approval
August 11, 2026 11:00 — with
GitHub Actions
Inactive
There was a problem hiding this comment.
Pull request overview
Adds monadic transformation support to LockedPtr.
Changes:
- Adds lvalue, const-lvalue, and rvalue
transformoverloads. - Adds null and non-null transformation tests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
score/concurrency/locked_ptr.h |
Implements transformation APIs. |
score/concurrency/locked_ptr_test.cpp |
Tests transformation behavior. |
Suppressed comments (3)
score/concurrency/locked_ptr.h:239
- This overload also preserves top-level
const, so its result type diverges from the linked transform contract and can rejectconstmove-only return values. Strip top-level cv-qualification from the invocation result.
typename FuncResult = std::invoke_result_t<Func, const LockedPtr&>,
score/concurrency/locked_ptr.h:260
- The rvalue overload must also remove top-level cv-qualification; otherwise a callable returning a
constmove-only value cannot be wrapped even though transform should store the unqualified value type.
typename FuncResult = std::invoke_result_t<Func, LockedPtr>,
score/concurrency/locked_ptr_test.cpp:58
- These namespace-scope callable objects are also mutable globals, contrary to
docs/cpp-style-guide.md:29and MISRA 6.7.2. Use free functions orconstexpr,k-prefixed lambda constants instead.
auto move_ptr = [](LPtr2IntW&& ptr) {
return std::move(ptr);
};
auto get_obj = [](const LPtr2IntW& ptr) {
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| */ | ||
| template <typename Func, | ||
| typename = std::enable_if_t<std::is_invocable_v<Func, LockedPtr&>>, | ||
| typename FuncResult = std::invoke_result_t<Func, LockedPtr&>, |
| #include "score/concurrency/type_traits.h" | ||
| #include "score/concurrency/unlock_guard.h" | ||
|
|
||
| #include <score/optional.hpp> |
Comment on lines
+252
to
+254
| * The LockedPtr is moved into the callable by value, transferring lock ownership. | ||
| * Returns score::cpp::optional containing the result. | ||
| * @tparam Func Callable type that accepts LockedPtr by value and returns a non-void type. |
| typename = std::enable_if_t<std::is_invocable_v<Func, LockedPtr&>>, | ||
| typename FuncResult = std::invoke_result_t<Func, LockedPtr&>, | ||
| typename = std::enable_if_t<!std::is_void_v<FuncResult>>> | ||
| [[nodiscard]] auto transform(Func&& f) & -> score::cpp::optional<FuncResult> |
Comment on lines
+47
to
+50
| auto value_by_10 = [](LPtr2IntW& lp) { | ||
| return lp->value / 10.0; | ||
| }; | ||
| auto cvalue_by_10 = [](const LPtr2IntW& lp) { |
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.
Monadic interfaces help write functional code by supporting
transform,and_thenandor_else. This PR is to supporttransform.This makes the following possible.