mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 17:56:44 +02:00
[Analyzers][CPP] Turn on rule 26497 (#23119)
* Turn on warning 26497 This function function-name could be marked constexpr if compile-time evaluation is desired. * C++20 has constexpr swap * as constexpr is not only for compile time, make all functions that can be constexpr constexpr * constexpr functions are implicity inline
This commit is contained in:
@@ -421,8 +421,12 @@ void KeyDropDownControl::AddShortcutToControl(Shortcut shortcut, StackPanel tabl
|
||||
}
|
||||
}
|
||||
|
||||
// Disable 26497 this function should be evaluated at compile time
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 26497)
|
||||
// Get number of selected keys. Do not count -1 and 0 values as they stand for Not selected and None
|
||||
int KeyDropDownControl::GetNumberOfSelectedKeys(std::vector<int32_t> keyCodes)
|
||||
{
|
||||
return (int)std::count_if(keyCodes.begin(), keyCodes.end(), [](int32_t a) { return a != -1 && a != 0; });
|
||||
}
|
||||
}
|
||||
#pragma warning(pop)
|
||||
@@ -165,7 +165,7 @@ int XamlBridge::MessageLoop()
|
||||
|
||||
static const WPARAM invalidKey = (WPARAM)-1;
|
||||
|
||||
WPARAM GetKeyFromReason(winrt::Windows::UI::Xaml::Hosting::XamlSourceFocusNavigationReason reason)
|
||||
constexpr WPARAM GetKeyFromReason(winrt::Windows::UI::Xaml::Hosting::XamlSourceFocusNavigationReason reason)
|
||||
{
|
||||
auto key = invalidKey;
|
||||
if (reason == winrt::Windows::UI::Xaml::Hosting::XamlSourceFocusNavigationReason::Last || reason == winrt::Windows::UI::Xaml::Hosting::XamlSourceFocusNavigationReason::First)
|
||||
|
||||
@@ -592,13 +592,13 @@ bool Shortcut::CheckModifiersKeyboardState(KeyboardManagerInput::InputInterface&
|
||||
}
|
||||
|
||||
// Helper method for checking if a key is in a range for cleaner code
|
||||
bool in_range(DWORD key, DWORD a, DWORD b)
|
||||
constexpr bool in_range(DWORD key, DWORD a, DWORD b)
|
||||
{
|
||||
return (key >= a && key <= b);
|
||||
}
|
||||
|
||||
// Helper method for checking if a key is equal to a value for cleaner code
|
||||
bool equals(DWORD key, DWORD a)
|
||||
constexpr bool equals(DWORD key, DWORD a)
|
||||
{
|
||||
return (key == a);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user