Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-08-26 10:41:22

A couple of questions/observations:

> template<typename Archive, typename T>
> inline void save (Archive &ar, const std::complex<T>& z, const
> unsigned int) {
> ar << real (z);
> ar << imag (z);
> }

I presume that real imag return either primitives(float or double) or
references to these. So that tracking would not be an issue.

> template<typename Archive, typename T>
> inline void load (Archive &ar, std::complex<T>& z, const unsigned
> int) { T i, r;
> ar >> r;
> ar >> i;
> z = std::complex<T> (r, i);
> }

Hmm, loading to a temporary and then moving to a final destination could
create an issue with tracking. There are a couple of possibilities:

* if real/imag return references, then reformulate the above to:
    ar >> real(z);
    ar >> imag(z);
since this is now symetric with the save one could avoid the split entirely
and simplify it even more.

* use reset_object_address

b) what does "vector" refer to. it has no namespace associated with it.
Could this not easily be confused with std::vector?

> template<class Archive, class U>
> inline void save (Archive &ar, const vector<U> &v, const unsigned
> int) { unsigned int count = v.size();
> ar << count;
> typename vector<U>::const_iterator it = v.begin();
> while (count-- > 0) {
> ar << *it++;
> }
> }


I would like to see the following:

a) a better/more complete test for std::complex. This would be easy - just
use the current tests as a template. The std::complex serialization could
be placed into boost/serialization/utility?/complex.hpp - ? whatever std

b) vector I presume is uBlas vector and would be added to the uBlas
namespace/directory tree.

Robert Ramey

Boost list run by bdawes at, gregod at, cpdaniel at, john at