Make getId() a constexpr function and use arrow syntax to call it in Target.hpp instead of dereferencing a pointer

This commit is contained in:
Username404 2021-09-02 10:05:36 +02:00
parent 52474d6521
commit d6642f9ae5
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
2 changed files with 2 additions and 2 deletions

View File

@ -15,7 +15,7 @@ using namespace std;
#define IS(X) template<typename T, typename std::enable_if<std::is_base_of<X, T>::value>::type* = nullptr> #define IS(X) template<typename T, typename std::enable_if<std::is_base_of<X, T>::value>::type* = nullptr>
struct ParseComponent { struct ParseComponent {
[[nodiscard]] const type_info& getId() const { return typeid(*this); } [[nodiscard]] constexpr const type_info& getId() const { return typeid(*this); }
virtual ~ParseComponent() = default; virtual ~ParseComponent() = default;
}; };

View File

@ -69,7 +69,7 @@ public:
string transpileWithTree(const ParseTree& tree) { string transpileWithTree(const ParseTree& tree) {
output.str(string()); output.str(string());
for (const unique_ptr<ParseComponent>& component: tree) { for (const unique_ptr<ParseComponent>& component: tree) {
const type_info& id = (*component).getId(); const type_info& id = component->getId();
with(StandardComponents::Define); with(StandardComponents::Define);
with(StandardComponents::types::String); with(StandardComponents::types::String);
with(StandardComponents::Reference); with(StandardComponents::Reference);