Skip to content

Commit 5bf462b

Browse files
committed
create Macro objects in-place
1 parent 64d2833 commit 5bf462b

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
@@ -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>
@@ -3347,22 +3348,22 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33473348

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

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

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

0 commit comments

Comments
 (0)