Boost logo

Boost Users :

From: Piyush Kapadia (piyush.kapadia_at_[hidden])
Date: 2005-10-22 18:02:40


T is a template class name(generic)

-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Christian Henning
Sent: Saturday, October 22, 2005 6:56 PM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] When to close ofstream in XML serialize

You don't need the ofs.close() call. The destructor of std::ofstream
will take care of this.

What is T in your code? I think you need to pass an object in the
BOOST_SERIALIZATION_NVP macro. Take a look at the xml example in
demo_xml_save.cpp

Christian

On 10/22/05, Piyush Kapadia <piyush.kapadia_at_[hidden]> wrote:
>
>
>
> In following function code, ofs.close() results in failure to write last
end
> tag of XML archive, apparently because stream is closed before destructor
is
> executed, so when do we execute ofs.close() ? ofs.flush does not help
either
> or shell we skip executing any flush or close and just return from
function
> ?
>
>
>
> template<class T>
>
> void Serialize(const char * filename)
>
> {
>
> std::ofstream ofs(filename);
>
> assert(ofs.good());
>
> boost::archive::xml_oarchive oa(ofs);
>
> oa << BOOST_SERIALIZATION_NVP(T);
>
> ofs.close();
>
> }
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>

_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net