$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Bill Lear (rael_at_[hidden])
Date: 2005-01-21 13:29:37
I am curious why loading a vector of items from an input stream fails
using one method but works using a slightly different method.
Given a load method:
        template <class T>
        T* load(std::istream& in) {
            boost::archive::xml_iarchive ia(in);
            T* t;
            ia & BOOST_SERIALIZATION_NVP(t);
            return t;
        }
and use of it:
        vector<item>* v = load<vector<item> >(std::cin);
I get:
        uncaught exception:  stream error
But, when I use this load method:
        template<class T>
        void load(std::istream& in, std::vector<T*>& v) {
            boost::archive::xml_iarchive ia(in);
            ia >> BOOST_SERIALIZATION_NVP(v);
        }
and use it so:
        vector<item> v;
        load(std::cin, v);
it works perfectly.
Is there some reason the first method should fail?
Bill