Boost logo

Boost Users :

From: Wu Yinghui, Freddie (yhwu_at_[hidden])
Date: 2006-03-23 01:50:18


Hi all,

I found that uBLAS doesn't have Serialization support built in. So in my
code, I do the following:
===== snip =====
class A
{
     typedef boost::numeric::ublas::c_vector<float, 3> container_t;
public:
     // Other member functions...
private:
     friend class boost::serialization::access;
     template <typename Archive>
     void serialize(Archive &ar, unsigned int version)
     {
         container_t::pointer data = data_.data();
         container_t::value_type (*p)[3] =
             reinterpret_cast<container_t::value_type (*)[3]>(data);
         ar & boost::serialization::make_nvp("data", *p);
     }
private:
     // The data field to be serialized
     container_t data_;
};
===== snip =====

While this code seems to be working on my machine, there is
reinterpret_cast<> in place in order to grab the content of the vector,
as you can see. So my question is: Is this way of performing
serialization safe/ portable/ etc.?

Any idea?

Cheers,

Freddie

-- 
Wu Yinghui, Freddie
Research & Development
Software Engineer
Volume Interactions Pte Ltd
1 Kim Seng Promenade, #12-01
Great World City East Tower
Singapore 237994
Tel:   +65 62226962 (Ext 216)
Fax:   +65 62226215
Email: yhwu_at_[hidden]
URL:   http://www.volumeinteractions.com
Important:  This message is intended for the recipient(s) addressed 
above.  It contains privileged and confidential information.  If you are 
not the intended recipient, please notify the sender immediately by 
replying to this message and then delete it from your system.  You must 
not read, copy, use, or disseminate this communication in any form. 
Thank you.




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