Skip to content

Instantly share code, notes, and snippets.

@rmaicle
Created November 21, 2014 16:33
Show Gist options
  • Save rmaicle/ff36e876b11d79934ceb to your computer and use it in GitHub Desktop.
Save rmaicle/ff36e876b11d79934ceb to your computer and use it in GitHub Desktop.
Simple variant class using standard container for storage and small buffer optimization
class var
{
private:
std::size_t index;
static std::vector<int64_t> vsigned;
static std::vector<double> vdouble;
static std::vector<std::string> vstring;
public:
var() { }
var(bool v) : index(v) { }
var(std::size_t v) : index(v) { }
var(double v) : index(vdouble.size()) { vdouble.push_back(v); }
var(const char *v) : index(vstring.size()) { vstring.push_back(v); }
var(const std::string &v) : index(vstring.size()) { vstring.push_back(v); }
virtual ~var() { }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment