DEV Community

Discussion on: Is there a way to have raw-types in (modern) C++?

Collapse
 
pauljlucas profile image
Paul J. Lucas

Your Token should just contain a std::string inside it (that's a substring of the original string that was parsed). That's it. No templates involved at all. I don't see why that's a problem.

Collapse
 
baenencalin profile image
Calin Baenen

Because I want the data to be extremely-literal. - I want the Tokens to reflect their C++ values.

For example, I want a number/int token to be parsed, and reflected with C++'s built-in int type. E.g. Janky:13 = C++:Token<int>(13);

The reason I don't wanna use an std::string is because I have to parse the value later, when I could do it all at once, and not worry about it later. (This would be useful for easy-arithmetic between 2 tokens of the same type.)

Collapse
 
pauljlucas profile image
Paul J. Lucas

Have you looked at std::any?

Thread Thread
 
baenencalin profile image
Calin Baenen

No.
But it looks interesting.

Thanks for pointing me in s direction.