Skip to content

Commit 383e968

Browse files
committed
create Macro objects in-place
1 parent 9d77056 commit 383e968

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

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>
@@ -3384,22 +3385,22 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33843385

33853386
const bool strictAnsiUndefined = dui.undefined.find("__STRICT_ANSI__") != dui.undefined.cend();
33863387
if (!isGnu(dui) && !strictAnsiDefined && !strictAnsiUndefined)
3387-
macros.emplace("__STRICT_ANSI__", Macro("__STRICT_ANSI__", "1", dummy));
3388+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__STRICT_ANSI__"), std::forward_as_tuple("__STRICT_ANSI__", "1", dummy));
33883389

3389-
macros.emplace("__FILE__", Macro("__FILE__", "__FILE__", dummy));
3390-
macros.emplace("__LINE__", Macro("__LINE__", "__LINE__", dummy));
3391-
macros.emplace("__COUNTER__", Macro("__COUNTER__", "__COUNTER__", dummy));
3390+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__FILE__"), std::forward_as_tuple("__FILE__", "__FILE__", dummy));
3391+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__LINE__"), std::forward_as_tuple("__LINE__", "__LINE__", dummy));
3392+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__COUNTER__"), std::forward_as_tuple("__COUNTER__", "__COUNTER__", dummy));
33923393
struct tm ltime {};
33933394
getLocaltime(ltime);
3394-
macros.emplace("__DATE__", Macro("__DATE__", getDateDefine(&ltime), dummy));
3395-
macros.emplace("__TIME__", Macro("__TIME__", getTimeDefine(&ltime), dummy));
3395+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__DATE__"), std::forward_as_tuple("__DATE__", getDateDefine(&ltime), dummy));
3396+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__TIME__"), std::forward_as_tuple("__TIME__", getTimeDefine(&ltime), dummy));
33963397

33973398
if (!dui.std.empty()) {
33983399
const cstd_t c_std = simplecpp::getCStd(dui.std);
33993400
if (c_std != CUnknown) {
34003401
const std::string std_def = simplecpp::getCStdString(c_std);
34013402
if (!std_def.empty())
3402-
macros.emplace("__STDC_VERSION__", Macro("__STDC_VERSION__", std_def, dummy));
3403+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__STDC_VERSION__"), std::forward_as_tuple("__STDC_VERSION__", std_def, dummy));
34033404
} else {
34043405
const cppstd_t cpp_std = simplecpp::getCppStd(dui.std);
34053406
if (cpp_std == CPPUnknown) {
@@ -3416,7 +3417,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
34163417
}
34173418
const std::string std_def = simplecpp::getCppStdString(cpp_std);
34183419
if (!std_def.empty())
3419-
macros.emplace("__cplusplus", Macro("__cplusplus", std_def, dummy));
3420+
macros.emplace(std::piecewise_construct, std::forward_as_tuple("__cplusplus"), std::forward_as_tuple("__cplusplus", std_def, dummy));
34203421
}
34213422
}
34223423

0 commit comments

Comments
 (0)