Skip to content

Commit 8db68d2

Browse files
committed
Use __VA_ARGS__ in register macros
See #141 Should work across all compilers we currently support, for any other times when templated types are needed in a macro, just unroll the macro manually and replace as necessary
1 parent 4c9286e commit 8db68d2

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

include/cereal/details/polymorphic_impl.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@
5858
have been registered with CEREAL_REGISTER_ARCHIVE. This must be called
5959
after all archives are registered (usually after the archives themselves
6060
have been included). */
61-
#define CEREAL_BIND_TO_ARCHIVES(T) \
62-
namespace cereal { \
63-
namespace detail { \
64-
template<> \
65-
struct init_binding<T> { \
66-
static bind_to_archives<T> const & b; \
67-
static void unused() { (void)b; } \
68-
}; \
69-
bind_to_archives<T> const & init_binding<T>::b = \
70-
::cereal::detail::StaticObject< \
71-
bind_to_archives<T> \
72-
>::getInstance().bind(); \
61+
#define CEREAL_BIND_TO_ARCHIVES(...) \
62+
namespace cereal { \
63+
namespace detail { \
64+
template<> \
65+
struct init_binding<__VA_ARGS__> { \
66+
static bind_to_archives<__VA_ARGS__> const & b; \
67+
static void unused() { (void)b; } \
68+
}; \
69+
bind_to_archives<__VA_ARGS__> const & init_binding<__VA_ARGS__>::b = \
70+
::cereal::detail::StaticObject< \
71+
bind_to_archives<__VA_ARGS__> \
72+
>::getInstance().bind(); \
7373
}} /* end namespaces */
7474

7575
namespace cereal

include/cereal/types/polymorphic.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@
7979
8080
Polymorphic support in cereal requires RTTI to be
8181
enabled */
82-
#define CEREAL_REGISTER_TYPE(T) \
83-
namespace cereal { \
84-
namespace detail { \
85-
template <> \
86-
struct binding_name<T> \
87-
{ \
88-
STATIC_CONSTEXPR char const * name() { return #T; } \
89-
}; \
90-
} } /* end namespaces */ \
91-
CEREAL_BIND_TO_ARCHIVES(T)
82+
#define CEREAL_REGISTER_TYPE(...) \
83+
namespace cereal { \
84+
namespace detail { \
85+
template <> \
86+
struct binding_name<__VA_ARGS__> \
87+
{ \
88+
STATIC_CONSTEXPR char const * name() { return #__VA_ARGS__; } \
89+
}; \
90+
} } /* end namespaces */ \
91+
CEREAL_BIND_TO_ARCHIVES(__VA_ARGS__)
9292

9393
//! Registers a polymorphic type with cereal, giving it a
9494
//! user defined name

0 commit comments

Comments
 (0)