Skip to content

Avoid copying std::function objects needlessly in the test_throws infra#5329

Merged
randombit merged 1 commit intomasterfrom
jack/test-throw-no-copy
Feb 14, 2026
Merged

Avoid copying std::function objects needlessly in the test_throws infra#5329
randombit merged 1 commit intomasterfrom
jack/test-throw-no-copy

Conversation

@randombit
Copy link
Owner

No description provided.

Copy link

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 optimizes the test_throws test infrastructure by changing how std::function objects are passed to avoid unnecessary copying. The change switches from passing std::function by const reference to pass-by-value with move semantics, which eliminates an extra copy when lambdas are passed as temporary objects.

Changes:

  • Updated function signatures to take std::function<void()> by value instead of const reference
  • Added std::move() calls when constructing ThrowExpectations objects to enable move semantics

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/tests/tests.h Updated declarations and template implementations of test_throws and test_no_throw to use pass-by-value and std::move()
src/tests/tests.cpp Updated non-template implementations of test_throws and test_no_throw to use pass-by-value and std::move()

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

@randombit randombit merged commit fa5638d into master Feb 14, 2026
52 checks passed
@randombit randombit deleted the jack/test-throw-no-copy branch February 14, 2026 13:35
@coveralls
Copy link

Coverage Status

coverage: 90.065%. remained the same
when pulling e5c2e11 on jack/test-throw-no-copy
into 5f60b6b on master.

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