
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