Created
March 23, 2009 20:12
-
-
Save gaspard/83748 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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