Skip to content

Instantly share code, notes, and snippets.

@gaspard
Created March 23, 2009 20:12
Show Gist options
  • Save gaspard/83748 to your computer and use it in GitHub Desktop.
Save gaspard/83748 to your computer and use it in GitHub Desktop.
class Value
{
Value() : type_(NIL_TYPE_ID) {}
bool isReal()
{ return type_ == REAL_TYPE_ID; }
// special thing here: anonymous union
union {
real_t r;
int i;
const char * c;
};
uint type_;
};
// don't pass by value: constructor and destructor code will be called, even for small memory spaces
void compteur(const Value& val)
{
if (val.isReal())
compteur_ = val.r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment