Created
January 4, 2014 12:09
-
-
Save nurettin/8254816 to your computer and use it in GitHub Desktop.
who wants types?
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
#include <iostream> | |
#include <map> | |
#include <string> | |
#include <boost/variant.hpp> | |
typedef boost::variant<std::string, double, int> Data; | |
struct Graph: std::map<Data, Graph> | |
{ | |
Data data; | |
template <typename T> | |
Graph &operator= (T const &t) | |
{ | |
data= t; | |
return *this; | |
} | |
template <typename T> | |
operator T &(){ return boost::get<T>(data); } | |
std::string to_yaml() const | |
{ | |
return ""; | |
} | |
}; | |
int main() | |
{ | |
Graph omg; | |
omg["lol"][0]["name"]= "pwned"; | |
omg["lol"][0]["age"]= 42; | |
omg["lol"][1]["name"]= "noob"; | |
omg["lol"][1]["age"]= 21; | |
std::cout<< omg.to_yaml()<< '\n'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment