Fixing versioning for classes in namespaces

Fixes #99
This commit is contained in:
Shane Grant
2014-05-12 10:22:38 -07:00
parent fd73e8066f
commit d85d8136e1
2 changed files with 18 additions and 4 deletions
+4 -4
View File
@@ -197,15 +197,15 @@ namespace cereal
namespace cereal { namespace detail { \
template <> struct Version<TYPE> \
{ \
static const std::uint32_t version = VERSION_NUMBER; \
static Version<TYPE> registerVersion() \
static const std::uint32_t version; \
static std::uint32_t registerVersion() \
{ \
::cereal::detail::StaticObject<Versions>::getInstance().mapping.emplace( \
std::type_index(typeid(TYPE)).hash_code(), VERSION_NUMBER ); \
return {}; \
return VERSION_NUMBER; \
} \
}; /* end Version */ \
static const auto CEREAL_CLASS_VERSION_REGISTER##TYPE##VERSION_NUMBER = \
const std::uint32_t Version<TYPE>::version = \
Version<TYPE>::registerVersion(); \
} } // end namespaces
+14
View File
@@ -27,6 +27,20 @@
#include "common.hpp"
#include <boost/test/unit_test.hpp>
namespace Nested
{
struct NestedClass
{
int x;
template <class Archive>
void serialize( Archive & ar )
{ ar( x ); }
};
}
CEREAL_CLASS_VERSION( Nested::NestedClass, 1 )
class VersionStructMS
{
public: