Boost logo

Boost :

From: troy d. straszheim (troy_at_[hidden])
Date: 2005-03-27 08:51:39


Notice that split_free.hpp is for when you have split save/load
*freestanding* functions, and split_member.hpp is for when you have
split save/load *member* functions. I can't reproduce your error (I
don't do Microsoft), but I'll guess that's it, since split_free.hpp
isn't required by the code you posted, and that's where your error is
coming from.

You could also try running the serialization tests on your platform. at
$BOOST_ROOT/libs/serialization/test. There are surely a couple of tests
in there that demonstrate the technique...

troy d. straszheim

jason wrote:
> I'm all new to C++, let alone Boost, so do excuse me if this is a dumb
> post, I've only been using C++ for a few weeks now, and come froma web
> design background.
>
> Anyway, I am getting a
>
> Error C2780 .\boost_1_32_0\boost\serialization\split_free.hpp(45): error
> C2780: 'void boost::archive::save(Archive &,const T &)' : expects 2
> arguments - 3 provided
>
> message when I use STL containers in Boost and the
> BOOST_SERIALIZATION_SPLIT_MEMBER() macro in my class. I have found when
> I don't split the serialize method into load / save methods it works
> fine. However, I need separate load / save methods as some of the
> members in my class are not serializable (they are SDL resources, and
> therefore uploading I need to do some other work to restore these members).
>
> Here is a chunk of example code that fails...
>
> class P {
> private:
> int qw;
>
> friend class boost::serialization::access;
>
> template<class Archive>
> void serialize(Archive& ar, const unsigned int version)
> {
> ar & qw;
> }
> public:
> P() : qw(0) {}
> P(int Qw) : qw(Qw) {}
> };
>
> typedef std::list<P*> pList;
>
> class Test {
> pList p;
>
> friend class boost::serialization::access;
> BOOST_SERIALIZATION_SPLIT_MEMBER()
>
> template<class Archive>
> void load(Archive& ar, const unsigned int version)
> {
> ar & p;
> }
>
> template<class Archive>
> void save(Archive& ar, const unsigned int version) const
> {
> ar & p;
> }
>
> public:
> Test() {}
> };
>
> Using
>
> Test t;
> std::ofstream ofs("frameTest");
> boost::archive::text_oarchive oa(ofs);
> oa << t;
> ofs.close();
>
> creates this error. To me it seems like this might be a library issue.
> However could someone point out what I am doing wrong if it is me, and
> if it is a lib issue, could they hint /suggest some sort of cleanish
> workaround. I am going to mess about and hack together a workaround by
> not splitting the serialize method into load/save methods in the class
> affected for now, however I'm sure other people on this list will be
> able to suggest better solutions than mine.
>
> And yes, I am including the list.hpp file incase anyone thinks I'm not
> including it.
>
> Jason.
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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