Make the members of the tok structure non-const to avoid undefined behaviour when the "=" operator is called
Signed-off-by: Username404 <w.iron.zombie@gmail.com>
This commit is contained in:
parent
beb28ef4ad
commit
63b24752d6
|
@ -20,17 +20,9 @@ struct tok {
|
|||
static auto inverseLCharacter(const unsigned char& character) {
|
||||
return static_cast<unsigned char>(((character + 2) - (character == tok::LPAR)));
|
||||
};
|
||||
const type toktype;
|
||||
const std::string toktext;
|
||||
const unsigned long line;
|
||||
tok& operator=(const tok& other) {
|
||||
if (this != &other) {
|
||||
const_cast<type&>(toktype) = other.toktype;
|
||||
const_cast<std::string&>(toktext) = other.toktext;
|
||||
const_cast<unsigned long&>(line) = other.line;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
type toktype;
|
||||
std::string toktext;
|
||||
unsigned long line;
|
||||
tok(): toktype(UNEXPECTED), toktext(), line(0) {};
|
||||
tok(const type& Type, std::string_view Text, const decltype(line)& line = 0): toktype(Type), toktext(Text), line(line) {}
|
||||
explicit tok(const type& Type, const decltype(line)& line = 0): tok(Type, std::string(1, Type), line) {};
|
||||
|
|
Loading…
Reference in New Issue