Hacker News new | ask | show | jobs
by nly 4418 days ago
That's tricky, because C++ is statically typed and you've selected a varying value type, but here's the closest thing in real terms.

    #include <map>
    #include <vector>
    #include <string>
    #include <boost/any.hpp>
    using boost::any;
    using std::map;
    using std::string;
    using std::vector;

    int main() {
        map<string,any> x = {{"foo", 34}, {"bar", vector<int>{1,2,3}}, {"bar", "quux"}};
    }
Syntax overhead amortizes to constant factor ;)