Skip to content

CXXCBC-774: Fix incorrect use of std::move on const Document& parameter#903

Merged
avsej merged 1 commit intocouchbase:mainfrom
avsej:CXXCBC-774-fix-const-reference-argument-in-move-context
Mar 13, 2026
Merged

CXXCBC-774: Fix incorrect use of std::move on const Document& parameter#903
avsej merged 1 commit intocouchbase:mainfrom
avsej:CXXCBC-774-fix-const-reference-argument-in-move-context

Conversation

@avsej
Copy link
Copy Markdown
Member

@avsej avsej commented Mar 12, 2026

Changed upsert(), insert(), and replace() to take Document by value instead of const Document&. This correctly supports:

  • lvalues → copied (backward compatible)
  • rvalues → moved (was broken before)

The previous signature const Document& with std::move() internally caused compilation errors since std::move on a const lvalue produces an rvalue reference that cannot bind to non-const lvalue parameters.

Changed upsert(), insert(), and replace() to take Document by value
instead of const Document&. This correctly supports:
- lvalues → copied (backward compatible)
- rvalues → moved (was broken before)

The previous signature const Document& with std::move() internally
caused compilation errors since std::move on a const lvalue produces
an rvalue reference that cannot bind to non-const lvalue parameters.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes move semantics for the public KV mutation APIs on couchbase::collection by changing the templated upsert(), insert(), and replace() overloads to take Document by value, enabling correct copy behavior for lvalues and move behavior for rvalues.

Changes:

  • Update collection::upsert() templated future-returning overload to take Document by value.
  • Update collection::insert() templated future-returning overload to take Document by value.
  • Update collection::replace() templated future-returning overload to take Document by value.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@avsej avsej merged commit 06d4a27 into couchbase:main Mar 13, 2026
48 of 53 checks passed
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.

3 participants