Avoid using std::get except in holds_alternative-asserting accessors

This commit is contained in:
Rangi42
2024-03-03 23:33:23 -05:00
parent 13904dc536
commit f2c875e71e
6 changed files with 23 additions and 8 deletions

View File

@@ -16,6 +16,18 @@
std::map<std::string, Symbol *> symbols;
Label &Symbol::label()
{
assert(std::holds_alternative<Label>(data));
return std::get<Label>(data);
}
Label const &Symbol::label() const
{
assert(std::holds_alternative<Label>(data));
return std::get<Label>(data);
}
void sym_AddSymbol(Symbol &symbol)
{
// Check if the symbol already exists