[uBLAS + Serialization] Is This Safe?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[uBLAS + Serialization] Is This Safe?

Wu Yinghui, Freddie
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: [hidden email]
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 mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users

yhwu.vcf (800 bytes) Download Attachment
signature.asc (194 bytes) Download Attachment