[serialization] "Archive" type turns into abstract class during save/load!

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[serialization] "Archive" type turns into abstract class during save/load!

Boost - Users mailing list
In a member load function function I call a static method that loads
another archive file, i.e. something like this:

```c++
struct Bar;
struct Foo
{
     std::shared_ptr<Bar> data;
     template <class Archive>
     void load(Archive& archive, const unsigned /*version*/)
     {
         std::string key;
         archive >> key;
         data = Bar::loadSomewhere<Archive>(std::move(key));
     }
};
struct Bar
{
     template <class Archive>
     std::shared_ptr<Bar> loadSomewhere(std::string key)
     {
         std::ifstream input(key);
         Archive ar(input);
         std::shared_ptr<Bar> bar(new Bar());
         ar >> *bar;
         return bar;
     }
};
```

The problem is that `Bar::loadSomewhere` is passed a
`boost::archive::polymorphic_iarchive`, while I invoke the serialization
library with a `boost::archive::xml_iarchive`. This is an abstract
class, so I can't instantiate it! So somewhere down the road the
`xml_iarchive` is turned into a `polymorphic_iarchive`. I would like to
prevent this from happening, because I instantiate an `Archive` object
in the `Bar::loadSomewhere` function. How can I get around this problem?
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Loading...