Merge "init: enable C++17"

This commit is contained in:
Tom Cherry 2017-03-14 17:17:39 +00:00 committed by Gerrit Code Review
commit e3aef3dd99
2 changed files with 6 additions and 8 deletions

View File

@ -17,6 +17,7 @@ init_cflags += \
-Wall -Wextra \
-Wno-unused-parameter \
-Werror \
-std=gnu++1z \
# --

View File

@ -146,8 +146,7 @@ bool Action::ParsePropertyTrigger(const std::string& trigger, std::string* err)
std::string prop_value(prop_name.substr(equal_pos + 1));
prop_name.erase(equal_pos);
auto res = property_triggers_.emplace(prop_name, prop_value);
if (res.second == false) {
if (auto [it, inserted] = property_triggers_.emplace(prop_name, prop_value); !inserted) {
*err = "multiple property triggers found for same property";
return false;
}
@ -212,9 +211,7 @@ bool Action::CheckPropertyTriggers(const std::string& name,
}
bool found = name.empty();
for (const auto& t : property_triggers_) {
const auto& trigger_name = t.first;
const auto& trigger_value = t.second;
for (const auto& [trigger_name, trigger_value] : property_triggers_) {
if (trigger_name == name) {
if (trigger_value != "*" && trigger_value != value) {
return false;
@ -251,10 +248,10 @@ bool Action::TriggersEqual(const Action& other) const {
std::string Action::BuildTriggersString() const {
std::string result;
for (const auto& t : property_triggers_) {
result += t.first;
for (const auto& [trigger_name, trigger_value] : property_triggers_) {
result += trigger_name;
result += '=';
result += t.second;
result += trigger_value;
result += ' ';
}
if (!event_trigger_.empty()) {