Skip to content

Commit 539da46

Browse files
committed
create Macro objects in-place
1 parent 3d24df6 commit 539da46

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
@@ -47,6 +47,7 @@
4747
#ifdef SIMPLECPP_WINDOWS
4848
# include <mutex>
4949
#endif
50+
#include <tuple>
5051
#include <unordered_map>
5152
#include <utility>
5253
#include <vector>
@@ -3346,22 +3347,22 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33463347

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

3351-
macros.emplace("__FILE__", Macro("__FILE__", "__FILE__", dummy));
3352-
macros.emplace("__LINE__", Macro("__LINE__", "__LINE__", dummy));
3353-
macros.emplace("__COUNTER__", Macro("__COUNTER__", "__COUNTER__", dummy));
3352+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__FILE__"), std::forward_as_tuple("__FILE__", "__FILE__", dummy));
3353+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__LINE__"), std::forward_as_tuple("__LINE__", "__LINE__", dummy));
3354+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__COUNTER__"), std::forward_as_tuple("__COUNTER__", "__COUNTER__", dummy));
33543355
struct tm ltime = {};
33553356
getLocaltime(ltime);
3356-
macros.emplace("__DATE__", Macro("__DATE__", getDateDefine(&ltime), dummy));
3357-
macros.emplace("__TIME__", Macro("__TIME__", getTimeDefine(&ltime), dummy));
3357+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__DATE__"), std::forward_as_tuple("__DATE__", getDateDefine(&ltime), dummy));
3358+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__TIME__"), std::forward_as_tuple("__TIME__", getTimeDefine(&ltime), dummy));
33583359

33593360
if (!dui.std.empty()) {
33603361
const cstd_t c_std = simplecpp::getCStd(dui.std);
33613362
if (c_std != CUnknown) {
33623363
const std::string std_def = simplecpp::getCStdString(c_std);
33633364
if (!std_def.empty())
3364-
macros.emplace("__STDC_VERSION__", Macro("__STDC_VERSION__", std_def, dummy));
3365+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__STDC_VERSION__"), std::forward_as_tuple("__STDC_VERSION__", std_def, dummy));
33653366
} else {
33663367
const cppstd_t cpp_std = simplecpp::getCppStd(dui.std);
33673368
if (cpp_std == CPPUnknown) {
@@ -3378,7 +3379,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33783379
}
33793380
const std::string std_def = simplecpp::getCppStdString(cpp_std);
33803381
if (!std_def.empty())
3381-
macros.emplace("__cplusplus", Macro("__cplusplus", std_def, dummy));
3382+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__cplusplus"), std::forward_as_tuple("__cplusplus", std_def, dummy));
33823383
}
33833384
}
33843385

0 commit comments

Comments
 (0)