Skip to content

Add requires clauses to libmiral templates#4764

Open
AlanGriffiths wants to merge 4 commits intomainfrom
modernise-miral
Open

Add requires clauses to libmiral templates#4764
AlanGriffiths wants to merge 4 commits intomainfrom
modernise-miral

Conversation

@AlanGriffiths
Copy link
Contributor

These shouldn't change the meaning of correct code, but can give better diagnostics when template requirements are not met

Copilot AI review requested due to automatic review settings March 11, 2026 14:08
@AlanGriffiths AlanGriffiths requested a review from a team as a code owner March 11, 2026 14:08
Copy link
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 adds C++20 requires constraints to several MirAL templates to improve compile-time diagnostics when users provide incompatible types, without changing behavior for valid usages.

Changes:

  • Constrain window management policy helpers to require WindowManagementPolicy-derived, constructible policy types.
  • Constrain lambda-based APIs (lambda_as_function, ConfigurationOption generic ctor) to require an addressable operator().
  • Constrain internal-client and application-authorizer templates to require the expected callable/policy shapes.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
include/miral/miral/window_management_options.h Adds constraints on add_window_manager_policy() template parameters.
include/miral/miral/set_window_management_policy.h Adds constraints on set_window_management_policy() template parameters.
include/miral/miral/lambda_as_function.h Adds a requires constraint for clearer diagnostics when converting lambdas to std::function.
include/miral/miral/internal_client.h Adds requires constraints to internal-client templates to enforce expected call signatures.
include/miral/miral/configuration_option.h Adds a requires constraint for the generic callback constructor.
include/miral/miral/application_authorizer.h Adds constraints to ensure Policy derives from ApplicationAuthorizer and is constructible.
Comments suppressed due to low confidence (1)

include/miral/miral/configuration_option.h:165

  • This constructor forwards the callback with std::forward, but this header doesn’t include . Please add to make the header self-contained and avoid build breaks if transitive includes change.
    ConfigurationOption(
            Lambda&& callback,
            std::string const& option,
            std::string const& description) :
            ConfigurationOption(lambda_as_function(std::forward<Lambda>(callback)), option, description) {}

@AlanGriffiths
Copy link
Contributor Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Mar 11, 2026

@AlanGriffiths I've opened a new pull request, #4765, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits March 11, 2026 14:38
@github-actions
Copy link

TICS Quality Gate

✔️ Passed

mir

Coding Standards: ✔️ Passed

✔️ Condition “No new Coding Standard Violations for level 1, 2, 3 with respect to Previous analysis” passed.

See the results in the TICS Viewer

The following files have been checked for this project
  • include/miral/miral/application_authorizer.h
  • include/miral/miral/configuration_option.h
  • include/miral/miral/internal_client.h
  • include/miral/miral/lambda_as_function.h
  • include/miral/miral/set_window_management_policy.h
  • include/miral/miral/window_management_options.h

TICS / TICS / Run TICS analysis

Copy link
Contributor

@mattkae mattkae left a comment

Choose a reason for hiding this comment

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

Neat!

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.

4 participants