summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2017-03-13 11:58:58 -0700
committerTom Cherry <tomcherry@google.com>2017-03-13 11:58:58 -0700
commit2bc00140be22f08964102068a736358fe8dde5da (patch)
treecf0c1d9307b0078c837e9d4d1998d7475a5df407
parent76850afa52ded23a03f4ac225edb7fd0f035975c (diff)
init: enable C++17
Test: Boot bullhead Change-Id: I40961ff765461e8aef211d27158ffb7c4be76493
-rw-r--r--init/Android.mk1
-rw-r--r--init/action.cpp13
2 files changed, 6 insertions, 8 deletions
diff --git a/init/Android.mk b/init/Android.mk
index 1a47eb441..2a1ad9cdb 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -17,6 +17,7 @@ init_cflags += \
-Wall -Wextra \
-Wno-unused-parameter \
-Werror \
+ -std=gnu++1z \
# --
diff --git a/init/action.cpp b/init/action.cpp
index 65bf29277..09de81a5a 100644
--- a/init/action.cpp
+++ b/init/action.cpp
@@ -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()) {