Fix const_cast and rearrange logic in senseApi method
This commit is contained in:
@@ -65,7 +65,7 @@ void SenseApiManager::registerSenseApi(const SenseApiInstance& apiInstance)
|
|||||||
auto it = std::find_if(
|
auto it = std::find_if(
|
||||||
senseApiInstances.begin(), senseApiInstances.end(),
|
senseApiInstances.begin(), senseApiInstances.end(),
|
||||||
[&apiInstance](const std::unique_ptr<SenseApiInstance>& instance) {
|
[&apiInstance](const std::unique_ptr<SenseApiInstance>& instance) {
|
||||||
return static_cast<const SenseApiInstance&>(*instance) == apiInstance;
|
return const_cast<const SenseApiInstance&>(*instance) == apiInstance;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -88,9 +88,11 @@ void SenseApiManager::unregisterSenseApi(const SenseApiInstance& apiInstance)
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (it != senseApiInstances.end()) {
|
if (it == senseApiInstances.end())
|
||||||
senseApiInstances.erase(it);
|
{
|
||||||
} else {
|
|
||||||
std::cerr << std::string(__func__) + ": Sense API Instance not found.\n";
|
std::cerr << std::string(__func__) + ": Sense API Instance not found.\n";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
senseApiInstances.erase(it);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user