Algorithms: Introduce helper Utils::equal

Takes a member (function) pointer and a value and returns a functor,
that takes a instance of the mfp's class and returns whether it's equal
to value. Sounds complicated, but is a common pattern that is easy to
understand.

Change-Id: Iaaeb90488d34ddfd6940dadd4c66705381198fee
Reviewed-by: Nikita Baryshnikov <nib952051@gmail.com>
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Daniel Teske
2014-07-10 12:57:06 +02:00
parent eccf1dc1e3
commit 16ac3928a0
13 changed files with 34 additions and 46 deletions

View File

@@ -680,9 +680,7 @@ void Target::updateDefaultRunConfigurations()
// Try to find a runconfiguration that matches the project name. That is a good
// candidate for something to run initially.
selected = Utils::findOr(newConfigured, selected,
[this] (RunConfiguration *rc) {
return rc->displayName() == project()->displayName();
});
Utils::equal(&RunConfiguration::displayName, project()->displayName()));
setActiveRunConfiguration(selected);
} else if (!newUnconfigured.isEmpty()){
setActiveRunConfiguration(newUnconfigured.at(0));