Avoiding void pointers

class. It is meant to store a token read from the source file, with the content of the token, it's type, and the line at which it was encountered.

A token can be either a single-character symbol, a lenghtful string, a number, or a name. So it needs to be able to store different data types, either a character for symbols, a double for numbers, and a std::string for names and strings.

The way I'm implementing this is by storing that value in a void pointer, and by adding an attribute of a custome enum which helps understand what type should you cast that void pointer to.

Of course I could have a class for each of those subtypes of Token, but I would at some point anyway need to store all of them as a

Token*

, which means I will still need to have an enum which helps me know what type should I cast that

What is a good design pattern to implement this which avoids the use of void pointers and (possibly) enums? Everyone keeps telling me that this design is wrong, but I got no suggestions on how to actually improve this situation, so I asked here.

The instance will be correctly deleted for the smart pointer knows the type.
In a similar manner, by means of a bunch of specializations of proto, you can define different operations for the multiple types you want to deal with.