From 15d6d7f7650b4bdb0e4e90752aa151fa0424a448 Mon Sep 17 00:00:00 2001 From: Avi Robinson-Mosher Date: Sun, 14 Dec 2014 18:12:48 -0500 Subject: [PATCH] allow for cereal to be applied to template class names with multiple arguments --- include/cereal/details/polymorphic_impl.hpp | 22 ++++++++++----------- include/cereal/types/polymorphic.hpp | 20 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/cereal/details/polymorphic_impl.hpp b/include/cereal/details/polymorphic_impl.hpp index a91805fc1..8074d7b3e 100644 --- a/include/cereal/details/polymorphic_impl.hpp +++ b/include/cereal/details/polymorphic_impl.hpp @@ -56,17 +56,17 @@ have been registered with CEREAL_REGISTER_ARCHIVE. This must be called after all archives are registered (usually after the archives themselves have been included). */ -#define CEREAL_BIND_TO_ARCHIVES(T) \ - namespace cereal { \ - namespace detail { \ - template<> \ - struct init_binding { \ - static bind_to_archives const & b; \ - }; \ - bind_to_archives const & init_binding::b = \ - ::cereal::detail::StaticObject< \ - bind_to_archives \ - >::getInstance().bind(); \ +#define CEREAL_BIND_TO_ARCHIVES(...) \ + namespace cereal { \ + namespace detail { \ + template<> \ + struct init_binding<__VA_ARGS__> { \ + static bind_to_archives<__VA_ARGS__> const & b; \ + }; \ + bind_to_archives<__VA_ARGS__> const & init_binding<__VA_ARGS__>::b = \ + ::cereal::detail::StaticObject< \ + bind_to_archives<__VA_ARGS__> \ + >::getInstance().bind(); \ }} // end namespaces namespace cereal diff --git a/include/cereal/types/polymorphic.hpp b/include/cereal/types/polymorphic.hpp index 22e18af6f..accc1eabe 100644 --- a/include/cereal/types/polymorphic.hpp +++ b/include/cereal/types/polymorphic.hpp @@ -59,16 +59,16 @@ Polymorphic support in cereal requires RTTI to be enabled */ -#define CEREAL_REGISTER_TYPE(T) \ - namespace cereal { \ - namespace detail { \ - template <> \ - struct binding_name \ - { \ - STATIC_CONSTEXPR char const * name() { return #T; } \ - }; \ - } } /* end namespaces */ \ - CEREAL_BIND_TO_ARCHIVES(T) +#define CEREAL_REGISTER_TYPE(...) \ + namespace cereal { \ + namespace detail { \ + template <> \ + struct binding_name<__VA_ARGS__> \ + { \ + STATIC_CONSTEXPR char const * name() { return #__VA_ARGS__; } \ + }; \ + } } /* end namespaces */ \ + CEREAL_BIND_TO_ARCHIVES(__VA_ARGS__) //! Registers a polymorphic type with cereal, giving it a //! user defined name