
-----Original Message----- From: "Riccardo Murri" [riccardo.murri@gmail.com] Date: 09/12/2010 11:58 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] mpi: sending/receiving different types
Hi Hicham,
<snip>
3. I just thought of using boost::variant<> over all the possible types.
I think this is the way to go; I'm attaching a sample program. Not sure this is exactly what you need, but could be enough to get you started.
Best regards, Riccardo
It's exactly what I was gonna do, thanks very much. The bit I am missing now is my question here: http://lists.boost.org/boost-users/2010/12/64797.php I don't know how to assign the most derived type to the variant at creation in the sender. In your code snippet, you explicitly construct c, then assign it to v. For me, I get given const Base& and I need to store the actual type. This seems to be what some of the boost libraries have to do themselves, but I can't remember which one exactly. I could intrusively add virtual functions to the classes but I don't want that, thanks Riccardo,