Boost logo

Boost :

From: John Reid (john.reid_at_[hidden])
Date: 2006-02-16 10:27:41


Hi,

The following will not compile although if the inheritance is public there are no problems. The documentation implies that it should work. I cannot find a friend function declaration to put in Derived that will make MSVC8 happy. I am using boost 1_33_1.

Oleg Abrosimov already reported this:
http://lists.boost.org/Archives/boost/2005/12/98305.php

Any feedback appreciated,
John Reid

#include <boost/archive/text_oarchive.hpp>
#include <list>
#include <fstream>

typedef std::list< int > base_t;

struct Derived :
        private base_t //*** change to public to compile ***
{
        friend class boost::serialization::access;
        template<class Archive>
        void serialize(Archive &ar, const unsigned int version)
        {
                // save/load base class information
                ar & boost::serialization::base_object< base_t >(*this);
        }
};

void save(Derived const & derived, const char * const filename)
{
     std::ofstream ofs(filename);
     boost::archive::text_oarchive oa(ofs);
     oa << derived;
}

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager (it.support_at_[hidden]). All files are scanned for viruses.
**********************************************************************


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk