Boost logo

Boost :

From: Neal Becker (ndbecker2_at_[hidden])
Date: 2005-08-29 07:05:42


Robert Ramey wrote:

> Neal Becker wrote:
>
>> You're right! I forgot, real() and imag() have been changed to now
>> return a ref (or const ref). This works with gcc-4.0.1, at least.
>> Does this look
>> OK? Does the ublas::vector stuff also need some nvp added?
>>
> well if imag and real return const an non-const references to T then you
> can simplify things to:
>
> namespace boost { namespace serialization {
> template<class Archive, class T>
> inline void serialize (Archive &ar, std::complex<T>& z, const
> unsigned int file_version) {
> ar & real(z);
> ar & imag(z);
> }
> }
> }
>

OK, How about this then?

namespace boost {
namespace serialization {

template<class T>
struct implementation_level<std::complex<T> >
{
  typedef mpl::integral_c_tag tag;
  // typedef mpl::int_<primitive_type> type;
  typedef mpl::int_<object_serializable> type;
  BOOST_STATIC_CONSTANT(
                        int,
                        value = implementation_level::type::value
                        );
};

template<class T>
struct tracking_level<std::complex<T> >
{
  typedef mpl::integral_c_tag tag;
  typedef mpl::int_<track_never> type;
  BOOST_STATIC_CONSTANT(
                        int,
                        value = tracking_level::type::value
                        );

};

}
}
namespace boost { namespace serialization {
template<class Archive, class T>
inline void serialize (Archive &ar, std::complex<T>& z, const
unsigned int file_version) {
  ar & boost::serialization::make_nvp ("real", real(z));
  ar & boost::serialization::make_nvp ("imag", imag(z));
  // ar & real(z);
  // ar & imag(z);
}
}
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk