[Uuid] Portable binary serialization.

I'm interested in using the portable binary serialization code in
[serialization]/example directory with Boost.Uuid. I've noticed that
there's a fall back template function for unrecognized types in
portable_binary_iarchive.hpp:
101 // default fall through for any types not specified here
102 template<class T>
103 void load(T & t){
104 boost::intmax_t l;
105 load_impl(l, sizeof(T));
106 // use cast to avoid compile time warning
107 t = static_cast<T>(l);
108 }
that relies on the sizeof operator. Short of replacing the sizeof
operator with a templated switch:
//Code Sample 1
//Start code
template <typename T>
std::size_t my_size_of { return sizeof(T); }
tempate <>
std::size_t my_size_ofboost::uuids::uuid { return
boost::uuids::uuid::static_size(); }
//End code
or using macros ala:
//CodeSample 2
//Start
template <typename T>
std::size_t my_size_of(T const & t) { return sizeof(T); }
tempate <>
std::size_t my_size_ofboost::uuids::uuid(boost::uuids::uuid const &) {
return boost::uuids::uuid::static_size(); }
#define sizeof(x) my_size_of(x)
#include

On 12 March 2010 17:16, Mostafa
, is their something less instrusive I could do to make it work with Boost.Uuid?
I've been a strong advocate of making UUID a POD, in which case the fallback is perfectly fine. I don't remember what Andy decided, but check whether the version you're using is a POD before worrying.

On Fri, 12 Mar 2010 14:28:27 -0800, Scott McMurray
On 12 March 2010 17:16, Mostafa
wrote: , is their something less instrusive I could do to make it work with Boost.Uuid?
I've been a strong advocate of making UUID a POD, in which case the fallback is perfectly fine.
I don't remember what Andy decided, but check whether the version you're using is a POD before worrying.
It's a POD type. So the point is indeed moot. Thanks. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
participants (2)
-
Mostafa
-
Scott McMurray