
Matthias Troyer wrote:
If you say that really need to know about each type I'm not going to dispute it. But I will say I'm not seeing it.
I sort of expect to see something like:
class mpi_oprimitive ... { mpioutputfunction m_out; template<typename T, std::size_t s> mpi_out{ // uh-oh programming error - no mpi size BOOST_STATIC_ASSERT(0 == s); }
mpiout_int<int, 2>(int t){ mpi_out(MPI_SHORT_INT(t))); } mpiout_int<int, 4>(int t){ mpi_out(MPI_LONG_INT(t))); } ...? void save(int t){ mpiout_int(t, sizeof(t)); } void save(short int t){ mpiout_int(t, sizeof(t)); } void save(long int t){ mpiout_int(t, sizeof(t)); } ..?
mpiout_uint<int, 2>(unsigned int t){ mpi_out(MPI_SHORT_INT(t))); } mpiout_uint<int, 4>(unsigned int t){ mpi_out(MPI_LONG_INT(t))); } ...? void save(unsigned int t){ mpiout_uint(t, sizeof(t)); } void save(const unsigned short int t){ mpiout_uint(t, sizeof(t)); } void save(const unsigned long int t){ mpiout_int(t, sizeof(t)); } ..? } ...
I'm not even suggesting this, I'm just explaining why adding "more" to the documentation or spec or whatever would have occurred to me.
Unfortunately it is not as easy since an arbitrary number of datatypes can be created by the user, e.g. for pairs, structs, arrays, ... . Hence there is not a limited list of types but a general template, and thus no automatic conversion takes place.
Ahh but these aren't handled in the mpi_?primitive class but rather in the mpi_archive class - assuming it were to follow the pattern in text and binary archives. here's what I envisioned when I factored the code in my archives. class text_archives template save_override( invoke code in oserialize if it's a primitive - redirect (eventually) to text_primitive if its an array - invoke array code if its an enum - invoke enum code if it's a pointer - invoke pionter code else invoke serialize code - this would handle all the types you mentin above - pairs, structs. etc. ... That is ONLY types marked primitive and C++ primitives have to be considered here. Since the types in questions are marked primitive and convertible to primitive, I believe that ONLY C++ integer types have to be considered in the mpi_?primitive classes. Looking at text_primitive and binary_primitive you can see this. A couple of types needed special handling. The can be filtered out in either the archive class or the primitive class. But most types need no special treatment. A couple do - bool is rendered as a character, char is rendered as a small binary number. But mostly this gets handled transparently. It also handles most of the hassle with different sizes for built-in types. Robert Ramey
Matthias
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost