Skip to content

Commit af3f67d

Browse files
committed
create Macro objects in-place
1 parent 694321b commit af3f67d

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

simplecpp.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#ifdef SIMPLECPP_WINDOWS
4949
# include <mutex>
5050
#endif
51+
#include <tuple>
5152
#include <unordered_map>
5253
#include <utility>
5354
#include <vector>
@@ -3348,22 +3349,22 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33483349

33493350
const bool strictAnsiUndefined = dui.undefined.find("__STRICT_ANSI__") != dui.undefined.cend();
33503351
if (!isGnu(dui) && !strictAnsiDefined && !strictAnsiUndefined)
3351-
macros.emplace("__STRICT_ANSI__", Macro("__STRICT_ANSI__", "1", dummy));
3352+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__STRICT_ANSI__"), std::forward_as_tuple("__STRICT_ANSI__", "1", dummy));
33523353

3353-
macros.emplace("__FILE__", Macro("__FILE__", "__FILE__", dummy));
3354-
macros.emplace("__LINE__", Macro("__LINE__", "__LINE__", dummy));
3355-
macros.emplace("__COUNTER__", Macro("__COUNTER__", "__COUNTER__", dummy));
3354+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__FILE__"), std::forward_as_tuple("__FILE__", "__FILE__", dummy));
3355+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__LINE__"), std::forward_as_tuple("__LINE__", "__LINE__", dummy));
3356+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__COUNTER__"), std::forward_as_tuple("__COUNTER__", "__COUNTER__", dummy));
33563357
struct tm ltime = {};
33573358
getLocaltime(ltime);
3358-
macros.emplace("__DATE__", Macro("__DATE__", getDateDefine(&ltime), dummy));
3359-
macros.emplace("__TIME__", Macro("__TIME__", getTimeDefine(&ltime), dummy));
3359+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__DATE__"), std::forward_as_tuple("__DATE__", getDateDefine(&ltime), dummy));
3360+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__TIME__"), std::forward_as_tuple("__TIME__", getTimeDefine(&ltime), dummy));
33603361

33613362
if (!dui.std.empty()) {
33623363
const cstd_t c_std = simplecpp::getCStd(dui.std);
33633364
if (c_std != CUnknown) {
33643365
const std::string std_def = simplecpp::getCStdString(c_std);
33653366
if (!std_def.empty())
3366-
macros.emplace("__STDC_VERSION__", Macro("__STDC_VERSION__", std_def, dummy));
3367+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__STDC_VERSION__"), std::forward_as_tuple("__STDC_VERSION__", std_def, dummy));
33673368
} else {
33683369
const cppstd_t cpp_std = simplecpp::getCppStd(dui.std);
33693370
if (cpp_std == CPPUnknown) {
@@ -3380,7 +3381,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33803381
}
33813382
const std::string std_def = simplecpp::getCppStdString(cpp_std);
33823383
if (!std_def.empty())
3383-
macros.emplace("__cplusplus", Macro("__cplusplus", std_def, dummy));
3384+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__cplusplus"), std::forward_as_tuple("__cplusplus", std_def, dummy));
33843385
}
33853386
}
33863387

0 commit comments

Comments
 (0)