Boost logo

Boost Users :

From: Istvan Buki (buki.istvan_at_[hidden])
Date: 2008-07-17 11:29:30


Dear Boost experts,

I'm trying to copy data between different types of fusion sequences with
limited success.
The example below shows what I'm trying to achieve.
Any good advice would be welcome.

namespace fields
{
  struct i ;
  struct l ;
  struct d ;
}

int
main()
{
  using namespace boost::fusion ;

  typedef map <
    pair< fields::i, int >,
    pair< fields::l, long >,
    pair< fields::d, double >
> map_type ;

  typedef vector< int, long, double > vect_t ;

  vect_t tup1( 1, 2, 3.0 ) ;
  map_type m = tup1 ; // OK. Works as expected
  vect_t tup2 = m ; // Error. Conversion not possible

 // expected result: tup1 == tup2
 }

Does fusion provide a way to achieve what I'm trying to do?

As a side question, I was wondering whether it is possible to synthetize the
vect_t type from map_type (with MPL?)
A concrete example where this could be useful is an application that
manipulates map_type objects and to
persist these objects it uses the SOCI database library that supports fusion
vectors. Before inserting a row in the database, the map_type object should
be converted to a vect_t object and when retrieving a row from the database
a vect_t object should converted to a map_type object.

Thanks for your help.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net