Boost logo

Boost Users :

Subject: [Boost-users] [Serialization] This compiles; but does it work?
From: Merrill Cornish (merrill.cornish_at_[hidden])
Date: 2016-02-18 22:20:42

mGraphFile is a data member of type boost:filesystem::path, which isn't
(as I understand) handled natively by Boost Serialization. I could define

     template<class Archive>
     void serialize(Archive& ar, boost::filesystem::path& p,
                    const unsigned int version);

but it is needed in only one place.

Below is an excerpt from an inline serialization function that I'm
already using. While it has a redundant step not needed for loading and
a different redundant step not needed for storing, it would seem to do
what I need. (The minor inefficiency of the redundant statements is of
no concern here.)

         std::string str = mGraphFile.string(); // redundant if loading
         ar & BOOST_SERIALIZATION_NVP(str);
         mGraphFile = str; // redundant if saving

Can anyone tell me if this will work, or do I need to implement the
serialize() function?

Merrill Cornish

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at