Boost logo

Boost Users :

Subject: [Boost-users] Compiler does not give error for missing serialize function
From: Elizabeta (elizabeta.petreska_at_[hidden])
Date: 2016-04-22 08:38:08

I have the following code :

class MyClass
    friend class boost::serialization::access;
    template<class Archive>
    void serialize(Archive &ar, const unsigned int version) {}

class MyClass2 : public MyClass {};

MyClass2* ss = new MyClass2;
std::ofstream ofs("C:\\test.xml");
boost::archive::xml_oarchive oa(ofs);
oa & boost::serialization::make_nvp("test",ss);

I am serializing trough the derived class pointer. The derived class doesnot
have serialize function. The Base have. And I was expecting compiler to give
me error that MyClass2 doesnot have serialize function. But this code
compiles without errors. I am using vs2010.

View this message in context:
Sent from the Boost - Users mailing list archive at

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at