[MPI] Serializing a class with a string data member

Hello, I'm trying to register a class (named A), because it will be a derived class. Calling BOOST_CLASS_EXPORT(A) will generate a lot of errors that look similar. Here is one of them: /usr/local/include/boost/mpi/datatype.hpp:184: error: no matching function for call to ‘assertion_failed(mpl_::failed************ boost::mpi::is_mpi_datatype<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::************)’ Here is the code: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <iostream> #include <boost/mpi.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> #include <boost/mpi/packed_oarchive.hpp> #include <boost/mpi/packed_iarchive.hpp> #include <boost/serialization/export.hpp> #include <boost/serialization/string.hpp> class A { friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & _text; } }; BOOST_CLASS_EXPORT(A); // I need to export A, because I will use // abstract base pointer. A is not a derived // class for simplicity here. int main(int argc, char * argv[]) { return 0; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - I've found that someone had the same problem ( http://groups.google.com/group/boost-list/msg/c9a0c133bddd783d ), but no solution was found. What am I doing wrong? Thanks, Mathieu Larose

Mathieu Larose wrote:
Hello,
I'm trying to register a class (named A), because it will be a derived class. Calling BOOST_CLASS_EXPORT(A) will generate a lot of errors that look similar. Here is one of them:
I've found that someone had the same problem ( http://groups.google.com/group/boost-list/msg/c9a0c133bddd783d ), but no solution was found.
What am I doing wrong?
Don't know, but here are some observations: 1) I think your code sample is incomplete because there was no std::string member 2) I think the latest version of BOOST_CLASS_EXPORT(A) requires A to have at least one virtual function. That doesn't look like your issue though. -- Sohail Somani http://uint32t.blogspot.com

I've added namespace boost { namespace mpi { template<> struct is_mpi_datatype<std::string> : public mpl::true_ { }; } } and everything works fine... 2009/7/4 Mathieu Larose <mat087@gmail.com>:
Hello,
I'm trying to register a class (named A), because it will be a derived class. Calling BOOST_CLASS_EXPORT(A) will generate a lot of errors that look similar. Here is one of them:
/usr/local/include/boost/mpi/datatype.hpp:184: error: no matching function for call to ‘assertion_failed(mpl_::failed************ boost::mpi::is_mpi_datatype<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::************)’
Here is the code:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <iostream> #include <boost/mpi.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> #include <boost/mpi/packed_oarchive.hpp> #include <boost/mpi/packed_iarchive.hpp> #include <boost/serialization/export.hpp> #include <boost/serialization/string.hpp>
class A { friend class boost::serialization::access;
template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & _text; } };
BOOST_CLASS_EXPORT(A); // I need to export A, because I will use // abstract base pointer. A is not a derived // class for simplicity here.
int main(int argc, char * argv[]) { return 0; }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
I've found that someone had the same problem ( http://groups.google.com/group/boost-list/msg/c9a0c133bddd783d ), but no solution was found.
What am I doing wrong?
Thanks, Mathieu Larose

On 5 Jul 2009, at 13:25, Mathieu Larose wrote:
I've added
namespace boost { namespace mpi { template<> struct is_mpi_datatype<std::string> : public mpl::true_ { }; } }
and everything works fine...
Does this really send the data? I would be very surprised if this worked. Can you send the full code - the example you sent does not even have a string member, and _text is undefined. Matthias
2009/7/4 Mathieu Larose <mat087@gmail.com>:
Hello,
I'm trying to register a class (named A), because it will be a derived class. Calling BOOST_CLASS_EXPORT(A) will generate a lot of errors that look similar. Here is one of them:
/usr/local/include/boost/mpi/datatype.hpp:184: error: no matching function for call to ‘assertion_failed(mpl_::failed************ boost::mpi::is_mpi_datatype<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::************)’
Here is the code:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <iostream> #include <boost/mpi.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_oarchive.hpp> #include <boost/mpi/packed_oarchive.hpp> #include <boost/mpi/packed_iarchive.hpp> #include <boost/serialization/export.hpp> #include <boost/serialization/string.hpp>
class A { friend class boost::serialization::access;
template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & _text; } };
BOOST_CLASS_EXPORT(A); // I need to export A, because I will use // abstract base pointer. A is not a derived // class for simplicity here.
int main(int argc, char * argv[]) { return 0; }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
I've found that someone had the same problem ( http://groups.google.com/group/boost-list/msg/c9a0c133bddd783d ), but no solution was found.
What am I doing wrong?
Thanks, Mathieu Larose
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Mathieu Larose
-
Matthias Troyer
-
Sohail Somani