Boost logo

Boost :

Subject: [boost] about serialization
From: lz_at_[hidden]
Date: 2013-08-29 07:47:15


hi!
I'm wonding if I can change the in "interface_oarchive.hpp":

    template<class T>
    Archive & operator<<(T & t){
        this->This()->save_override(t, 0);
        return * this->This();
    }
to
    template<class T>
    Archive & operator<<(const T & t){
        this->This()->save_override(t, 0);
        return * this->This();
    }
and in "polymorphic_oarchive_route.hpp"
    template<class T>
    polymorphic_oarchive & operator<<(T & t){
        return polymorphic_oarchive::operator<<(t);
    }
to
    template<class T>
    polymorphic_oarchive & operator<<(const T & t){
        return polymorphic_oarchive::operator<<(t);
    }
, so I can write code like this:
enum E {};
class C {
private:
        E e;
public:
        E getE() const;
        void setE(const E e);
};

template<class Archive>
                inline void save_construct_data(Archive & ar, const C * t, const unsigned int file_version) {
                // save data required to construct instance
                ar << t->getE();
                // without changing the liberary code, I'll have to write like this:
                //int x = t->getE();
                //ar << x;
}

I'm not sure about the changes, can anybody verify it?
--------------
lz_at_sina


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