Add requires clauses to libmiral templates#4764
Open
AlanGriffiths wants to merge 4 commits intomainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
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,ConfigurationOptiongeneric ctor) to require an addressableoperator(). - 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) {}
Contributor
Author
|
@copilot open a new pull request to apply changes based on the comments in this thread |
3 tasks
Contributor
|
@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. |
Co-authored-by: AlanGriffiths <9048879+AlanGriffiths@users.noreply.github.com>
TICS Quality Gate✔️ Passedmir
|
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.
These shouldn't change the meaning of correct code, but can give better diagnostics when template requirements are not met