Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fdcc13a

Browse files
committed
clang-tidy modernize-use-emplace fix
1 parent 3663d96 commit fdcc13a

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

examples/pluginmanager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class PluginRegistry
6969
{
7070
public:
7171
static PluginRegistry& Instance() { return instance; }
72-
void Register(const string& name, Factory factory) { plugins.push_back(make_pair(name, factory)); }
72+
void Register(const string& name, Factory factory) { plugins.emplace_back(name, factory); }
7373
void Print(ostream& out) const
7474
{
7575
for (auto& p: plugins)
@@ -140,7 +140,7 @@ class RegisteredPlugin : public Plugin
140140
RegisteredPlugin() : Plugin(NAME)
141141
{
142142
const Registration& dummy = registration;
143-
do { (void)(dummy); } while (0); // silence unused variable warning
143+
do { (void)(dummy); } while (false); // silence unused variable warning
144144
}
145145
private:
146146
static unique_ptr<Plugin> Create(Menu* menu) { return make_unique<T>(menu); }

include/cli/detail/split.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ class Text
9898
// Should come back into the word state after this.
9999
prev_state = State::word;
100100
state = State::escape;
101-
splitResult.push_back("");
101+
splitResult.emplace_back("");
102102
}
103103
else
104104
{
105105
state = State::word;
106-
splitResult.push_back(std::string(1, c));
106+
splitResult.emplace_back(1, c);
107107
}
108108
}
109109

@@ -167,7 +167,7 @@ class Text
167167
{
168168
state = State::sentence;
169169
sentence_type = ( c == '"' ? SentenceType::double_quote : SentenceType::quote);
170-
splitResult.push_back("");
170+
splitResult.emplace_back("");
171171
}
172172

173173
void RemoveEmptyEntries()

test/test_split.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE(SingleQuotedCases)
140140
BOOST_CHECK_EQUAL(strs[0], "first");
141141
BOOST_CHECK_EQUAL(strs[1], "foo \tbar");
142142

143-
split(strs, "first '\"second\" \"thirdh\"'"); // first '"second" "thirdh"'
143+
split(strs, R"(first '"second" "thirdh"')"); // first '"second" "thirdh"'
144144
BOOST_CHECK_EQUAL(strs.size(), 2);
145145
BOOST_CHECK_EQUAL(strs[0], "first");
146146
BOOST_CHECK_EQUAL(strs[1], "\"second\" \"thirdh\"");

0 commit comments

Comments
 (0)