I seem to remember being told that std::string was not meant to be inherited from, could it be the same in your case? -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Bill Lear Sent: 24 January 2005 13:43 To: boost-users@lists.boost.org Subject: Re: [Boost-users] Serialization problem loading a vector of items On Friday, January 21, 2005 at 12:29:37 (-0600) Bill Lear writes:
I am curious why loading a vector of items from an input stream fails using one method but works using a slightly different method. ...
I have not seen a response to this post. Along similar lines, I am having problems with sub-classing the std::vector class. I've tried multiple ways, but can't get it to load (de-serialize) properly. I've used private inheritance (my first choice), public inheritance. Neither work. Here is my attempt at public inheritance: template <class T> class RingBuffer: public std::vector<T> { public: RingBuffer() : _first_ind(0), _last_ind(0) { } double first() { return (*this)[_first_ind]; } double last() { return (*this)[_last_ind]; } void add(T v) { _last_ind = (_last_ind + 1) % size(); (*this)[_last_ind] = v; if (_last_ind == _first_ind) { _first_ind = (_first_ind + 1) % size(); } } private: int _first_ind; int _last_ind; friend class boost::serialization::access; template<class Archive> void serialize(Archive& ar, const unsigned int) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(std::vector<T>) & BOOST_SERIALIZATION_NVP(_first_ind) & BOOST_SERIALIZATION_NVP(_last_ind); } }; As before, I can save this to a stream, but cannot get it to load from a stream. I am using boost 1.32, with gcc 3.2. Bill _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users