mirror of
https://github.com/USCiLab/cereal.git
synced 2025-09-27 20:59:32 +02:00
testing macros for gcc 4.7
This commit is contained in:
parent
9085b6dc79
commit
8e5fa8ef33
@ -30,6 +30,10 @@
|
||||
#ifndef CEREAL_DETAILS_TRAITS_HPP_
|
||||
#define CEREAL_DETAILS_TRAITS_HPP_
|
||||
|
||||
#if (__GNUC__ == 4 && __GNUC_MINOR__ <= 7)
|
||||
#define CEREAL_OLDER_GCC
|
||||
#endif
|
||||
|
||||
#include <type_traits>
|
||||
#include <typeindex>
|
||||
#include <memory>
|
||||
@ -43,9 +47,21 @@ namespace cereal
|
||||
typedef std::true_type yes;
|
||||
typedef std::false_type no;
|
||||
|
||||
#ifdef CEREAL_OLDER_GCC // when VS supports better SFINAE, we can use this as the default
|
||||
template<typename> struct Void { typedef void type; };
|
||||
#endif // CEREAL_OLDER_GCC
|
||||
|
||||
//! Creates a test for whether a non const member function exists
|
||||
/*! This creates a class derived from std::integral_constant that will be true if
|
||||
the type has the proper member function for the given archive. */
|
||||
#ifdef CEREAL_OLDER_GCC
|
||||
#define CEREAL_MAKE_HAS_MEMBER_TEST(name) \
|
||||
template <class T, class A, class SFINAE = void> \
|
||||
struct has_member_##name : no; \
|
||||
template <class T, class A> \
|
||||
struct has_member_##name<T, A, \
|
||||
typename Void< decltype( cereal::access::member_##name( std::declval<AA&>(), std::declval<TT&>() ) ) >::type> : yes {};
|
||||
#else // NOT CEREAL_OLDER_GCC
|
||||
#define CEREAL_MAKE_HAS_MEMBER_TEST(name) \
|
||||
namespace detail \
|
||||
{ \
|
||||
@ -61,6 +77,7 @@ namespace cereal
|
||||
} /* end namespace detail */ \
|
||||
template <class T, class A> \
|
||||
struct has_member_##name : std::integral_constant<bool, detail::has_member_##name##_impl<T, A>::value> {}
|
||||
#endif // NOT CEREAL_OLDER_GCC
|
||||
|
||||
//! Creates a test for whether a non const non-member function exists
|
||||
/*! This creates a class derived from std::integral_constant that will be true if
|
||||
|
@ -174,47 +174,7 @@ int main()
|
||||
std::cout << typeid(A).name() << std::endl;
|
||||
std::cout << typeid(cereal::traits::has_load_and_allocate<int, bool>).name() << std::endl;
|
||||
|
||||
//Archive a;
|
||||
//T t;
|
||||
// extra testing
|
||||
|
||||
//cereal::access::member_save( a, t );
|
||||
//cereal::access::member_load( a, t );
|
||||
//cereal::access::member_serialize( a, t );
|
||||
|
||||
//std::stringstream ss;
|
||||
//{
|
||||
// cereal::JSONOutputArchive ar( ss );
|
||||
// ar( 5 );
|
||||
// ar( cereal::make_nvp("hello", 2.4f ) );
|
||||
// std::string s = "hey yo";
|
||||
// ar( CEREAL_NVP( s ) );
|
||||
// int darp [] = { 1, 2, 3 };
|
||||
// ar.saveBinaryValue( darp, sizeof(int) * 3, "darp" );
|
||||
// std::unique_ptr<A> ptr( new B() );
|
||||
// ar( CEREAL_NVP( ptr ) );
|
||||
//}
|
||||
//{
|
||||
// cereal::JSONInputArchive ar( ss );
|
||||
// int x;
|
||||
// ar( x );
|
||||
// assert( x == 5 );
|
||||
// float f;
|
||||
// ar( f );
|
||||
// assert( f == 2.4f );
|
||||
// std::string s;
|
||||
// ar( s );
|
||||
// assert( s == "hey yo" );
|
||||
// int darp[3];
|
||||
// ar.loadBinaryValue( darp, sizeof(int) * 3 );
|
||||
// assert( darp[0] == 1 );
|
||||
// assert( darp[1] == 2 );
|
||||
// assert( darp[2] == 3 );
|
||||
// std::unique_ptr<A> ptr;
|
||||
// std::cout << "----------" << std::endl;
|
||||
// std::cout << std::is_default_constructible<A>::value << std::endl;
|
||||
// std::cout << cereal::traits::has_load_and_allocate<A, cereal::JSONInputArchive>::value << std::endl;
|
||||
// ar( ptr );
|
||||
//}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user