From d6642f9ae5da857a8e16f13c45523e370b414b8c Mon Sep 17 00:00:00 2001 From: Username404 Date: Thu, 2 Sep 2021 10:05:36 +0200 Subject: [PATCH] Make getId() a constexpr function and use arrow syntax to call it in Target.hpp instead of dereferencing a pointer --- src/headers/parsing/ParseComponents.hpp | 2 +- src/headers/transpiler/Target.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/headers/parsing/ParseComponents.hpp b/src/headers/parsing/ParseComponents.hpp index 604d9e3..8e1bdb3 100644 --- a/src/headers/parsing/ParseComponents.hpp +++ b/src/headers/parsing/ParseComponents.hpp @@ -15,7 +15,7 @@ using namespace std; #define IS(X) template::value>::type* = nullptr> struct ParseComponent { - [[nodiscard]] const type_info& getId() const { return typeid(*this); } + [[nodiscard]] constexpr const type_info& getId() const { return typeid(*this); } virtual ~ParseComponent() = default; }; diff --git a/src/headers/transpiler/Target.hpp b/src/headers/transpiler/Target.hpp index 21feae7..24eeec4 100644 --- a/src/headers/transpiler/Target.hpp +++ b/src/headers/transpiler/Target.hpp @@ -69,7 +69,7 @@ public: string transpileWithTree(const ParseTree& tree) { output.str(string()); for (const unique_ptr& component: tree) { - const type_info& id = (*component).getId(); + const type_info& id = component->getId(); with(StandardComponents::Define); with(StandardComponents::types::String); with(StandardComponents::Reference);