Last active
July 12, 2016 10:45
-
-
Save OXPHOS/03d20339c3cf36a7a5cc11e3ab3fd7fe 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
#include "base.h" | |
using namespace std; | |
base::base() | |
{ | |
a = 3; | |
b = 2; | |
} | |
int base::add(int x, int y) | |
{ | |
return x + y; | |
} | |
template<class Archive> | |
void base::save(Archive & archive) const | |
{ | |
archive(a, b); | |
} | |
template<class Archive> | |
void base::load(Archive & archive) | |
{ | |
archive(a, b); | |
} |
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 | |
#ifndef base_h_ | |
#define base_h_ | |
using namespace std; | |
class base | |
{ | |
public: | |
int a, b; | |
base(); | |
int add(int x, int y); | |
template<class Archive> | |
void save(Archive & archive) const; | |
template<class Archive> | |
void load(Archive & archive); | |
}; | |
#endif | |
#undef CEREAL_SAVE_FUNCTION_NAME | |
#undef CEREAL_LOAD_FUNCTION_NAME |
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 "base.h" | |
using namespace std; | |
class derived : public base | |
{ | |
public: | |
int c, d; | |
derived() : base() | |
{ | |
c = 0; | |
d = -1; | |
} | |
}; |
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
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
Mac148934:test2 zora$ g++ -c -std=c++11 base.cpp | |
Mac148934:test2 zora$ g++ -c -std=c++11 test.cpp | |
Mac148934:test2 zora$ g++ -std=c++11 base.o test.o -o test | |
Undefined symbols for architecture x86_64: | |
"void base::serialize<cereal::JSONOutputArchive>(cereal::JSONOutputArchive&) const", referenced from: | |
decltype(fp0.serialize(fp)) cereal::access::member_serialize<cereal::JSONOutputArchive, derived>(cereal::JSONOutputArchive&, derived&) in test.o | |
ld: symbol(s) not found for architecture x86_64 | |
clang: error: linker command failed with exit code 1 (use -v to see invocation) |
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 "cereal/archives/json.hpp" | |
#include <fstream> | |
#include "derived.h" | |
using namespace std; | |
int main() | |
{ | |
derived d; | |
{ | |
std::ofstream os("cereatltest_save.cereal"); | |
cereal::JSONOutputArchive archive(os); | |
archive(d); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment