diff --git a/include/cereal/types/polymorphic.hpp b/include/cereal/types/polymorphic.hpp index 19d3171b..c692470c 100644 --- a/include/cereal/types/polymorphic.hpp +++ b/include/cereal/types/polymorphic.hpp @@ -31,7 +31,6 @@ #include #include #include -#include //! Registers a polymorphic type with cereal /*! Polymorphic types must be registered before pointers to them can be serialized. This also assumes that @@ -99,9 +98,7 @@ namespace cereal ar.registerPolymorphicName(nameid, name); } else - { name = ar.getPolymorphicName(nameid); - } auto & bindingMap = detail::StaticObject>::getInstance().map; @@ -152,8 +149,7 @@ namespace cereal typename std::enable_if::value, void>::type save( Archive & ar, std::weak_ptr const & ptr ) { - std::cout << "poly weak" << std::endl; - auto sptr = ptr.lock(); + auto const sptr = ptr.lock(); ar( sptr ); } diff --git a/sandbox_rtti.cpp b/sandbox_rtti.cpp index 90d77e40..07c8a6b2 100644 --- a/sandbox_rtti.cpp +++ b/sandbox_rtti.cpp @@ -51,6 +51,8 @@ struct Base struct MyType : public Base { + int x; + void foo() {} template @@ -69,18 +71,24 @@ CEREAL_REGISTER_TYPE(MyType); struct YourType : public Base { + YourType(int xx) : x(xx) {} + YourType() : x(-1) {} + int x; + void foo() {} template void save(Archive & ar) const { std::cout << "Saving YourType" << std::endl; + ar( x ); } template void load(Archive & ar) { std::cout << "Loading YourType" << std::endl; + ar( x ); } }; CEREAL_REGISTER_TYPE(YourType); @@ -94,7 +102,7 @@ int main() cereal::BinaryOutputArchive oarchive(ostream); std::shared_ptr ptr1 = std::make_shared(); - std::shared_ptr ptr2 = std::make_shared(); + std::shared_ptr ptr2 = std::make_shared(33); std::unique_ptr ptr3(new MyType); std::weak_ptr ptr4 = ptr2; @@ -104,8 +112,6 @@ int main() oarchive(ptr4); } - - { std::ifstream istream("rtti.txt"); cereal::BinaryInputArchive iarchive(istream); @@ -121,4 +127,5 @@ int main() iarchive(ptr4); } + //std::remove("rtti.txt"); }