Istvan Buki wrote:
Dear boost experts,
I have difficulties using the fusion join algorithm result.
Here is a small sample demonstrating the problem.
namespace fields
{
struct one ;
struct two ;
}
typedef fusion::map <
fusion::pair< fields::one, std::string >,
fusion::pair< fields::two, std::string >
> rec_t ;
int
main()
{
rec_t r1( std::string( "1" ), std::string( "2" ) ) ;
rec_t r2( std::string( "10" ), std::string( "20" ) ) ;
typedef fusion::result_of::join< const rec_t, const rec_t >::type res_type ;
res_type res = fusion::join( r1, r2 ) ;
// Compile error!
fusion::at_key< fields::two >( res ) = std::string( "200" ) ; std::cout << res << std::endl ;
}
I can not modify the map fields because they are const.
I tried changing the result type from
typedef fusion::result_of::join< const rec_t, const rec_t >::type res_type ;
to
typedef fusion::result_of::join< rec_t, rec_t >::type res_type ;
but that doesn't work neither.
Can somebody explain how to assign the result of a join to a variable that I can modify later
using functions like at_key, erase_key,... ?
When you join a sequence, A, and another sequence, B, the result is
a joint_sequence -- a view. IOTW, when you join a map and another
map, the result is not a map. What you can do is to convert the
view to a map using as_map(res).
Thanks for your help. It works now.
Is there any document that explains such things? I'm learning fusion and I'm really missing such a document that would go beyond the basic examples that appear in the documentation and would explain the connection between all the concepts used in fusion.
Best regards
Istvan Buki