Last active
July 18, 2016 03:19
-
-
Save OXPHOS/c59a016e20054ccb4095d7c22d352ed5 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
template<typename T> | |
void* createInstance() { return new T; } | |
void cast_to_type() | |
{ | |
typedef std::map<std::string, void*(*)()> map_type; | |
map_type map; | |
map["int"] = createInstance<int>; | |
map["double"] = createInstance<double>; | |
map["shogun::SGVector<int>"] = createInstance<shogun::SGVector<int> >; | |
map["shogun::SGVector<double>"] = createInstance<shogun::SGVector<double> >; | |
} |
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
#define CEREAL_SAVE_FUNCTION_NAME cereal_save | |
#define CEREAL_LOAD_FUNCTION_NAME cereal_load | |
template<class Archive> | |
void CSGObject::cereal_save(Archive& ar) const | |
{ | |
for (auto it = self->map.begin(); it != self->map.end(); ++it) | |
ar(it->second); // archive Any object | |
} | |
template void CSGObject::cereal_save<cereal::JSONOutputArchive>(cereal::JSONOutputArchive& ar) const; | |
template<class Archive> | |
void CSGObject::cereal_load(Archive& ar) | |
{ | |
} | |
template void CSGObject::cereal_load<cereal::JSONInputArchive>(cereal::JSONInputArchive& ar); | |
#undef CEREAL_SAVE_FUNCTION_NAME | |
#undef CEREAL_LOAD_FUNCTION_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment