Created
November 21, 2014 16:33
-
-
Save rmaicle/ff36e876b11d79934ceb to your computer and use it in GitHub Desktop.
Simple variant class using standard container for storage and small buffer optimization
This file contains hidden or 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 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