I have a weird union I am using for alignment reasons.
I have overloaded it so that it can be assigned a string value.
Now I wish to overload the = operator so that I can assign it TO a string value.
union Tag
{
std::string * path;
long id;
};
struct TextureID
{
Tag ID;
int type;
TextureID& operator= (std::string str){ ID.path = new std::string(str); type=0; }
TextureID& operator= (long val){ ID.id = val; type=1; }
};
In this case we have overloaded the operators such that
TextureID t = "hello";
Is a valid statement.
How may I overwrite the = operator to be able to do:
string s = t;