On 11/06/10 08:26, Christopher Schmidt wrote:
comments inline...
alfC schrieb: [snip]
One question: Why I can not interchange the order of p and q in the last call, after all it is a map at the library could in principle differentiate the pairs? making it possible to call an unordered named parameter. e.g. cout << H( map
, pair >( make_pair<q>(2.), // was p make_pair<p>(1.) // was q ) ); Is it possible to interchange the order to give more flexibility to the user?I don't think that this is a good idea. Reordering is a quite expensive operation and it would really slow down compile times. On top of that, fusion::map is a forward sequence which has a definite order (!) on its elements. Reordering does not feel natural here. Having that said, you can easily write your own, reordering associative sequence or you can construct your map from another another fusion sequence that you reorder on the fly, for example via fusion::nview .
The attached produces output: ------------------------- default values for tuple: ------------------------- at1=ti<1>(-1) at2=ti<2>(-1) at3=ti<3>(-1) ------------------------------- named/default values for tuple: ------------------------------- at1=ti<1>(1) at2=ti<2>(2) at3=ti<3>(-1) ================================ The args to pairs_nam_ti1_3_t CTOR could be the args to some map-like structure and then, inside that CTOR, a pairs_nam_ti1_3_t could be constructed and used to fill the map. It doesn't look too compile-time expensive, but I've done no measurements. HTH. -Larry