mirror of
https://github.com/USCiLab/cereal.git
synced 2025-10-18 01:45:52 +02:00
Having trouble getting non_member versions to work
This commit is contained in:
37
test.cpp
37
test.cpp
@@ -38,13 +38,20 @@ struct Test3
|
||||
int a;
|
||||
std::string b;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(int & ar, unsigned int version)
|
||||
{
|
||||
ar & a;
|
||||
}
|
||||
};
|
||||
|
||||
#if 1
|
||||
//namespace cereal
|
||||
//{
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, Test3 & t, unsigned int version)
|
||||
{
|
||||
//ar & t.a;
|
||||
//ar & t.b;
|
||||
}
|
||||
//}
|
||||
#endif
|
||||
|
||||
// ###################################
|
||||
struct Test4
|
||||
{
|
||||
@@ -70,6 +77,19 @@ struct Test4
|
||||
}
|
||||
};
|
||||
|
||||
//// ######################################################################
|
||||
//template<typename> struct Void { typedef void type; };
|
||||
//
|
||||
//template<typename T, class A, typename Sfinae = void>
|
||||
//struct has_non_member_serialize2: std::false_type {};
|
||||
//
|
||||
//template<typename T, class A>
|
||||
//struct has_non_member_serialize2< T, A,
|
||||
// typename Void<
|
||||
//decltype( cereal::serialize( std::declval<A&>(), std::declval<T&>(), 0 ) )
|
||||
// >::type
|
||||
// >: std::true_type {};
|
||||
|
||||
// ######################################################################
|
||||
int main()
|
||||
{
|
||||
@@ -80,13 +100,16 @@ int main()
|
||||
Test3 t3;
|
||||
Test4 t4;
|
||||
|
||||
archive & t1;
|
||||
archive & t2;
|
||||
//archive & t1;
|
||||
//archive & t2;
|
||||
//archive & t3;
|
||||
//archive & t4;
|
||||
|
||||
//cereal::serialize(archive, t3, 0);
|
||||
|
||||
|
||||
std::cout << cereal::traits::has_non_member_serialize<Test2, cereal::BinaryOutputArchive>() << std::endl;
|
||||
//std::cout << has_non_member_serialize2<Test3, cereal::BinaryOutputArchive>() << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user