On Mon, Jul 21, 2008 at 03:27:39PM +0200, Istvan Buki wrote:
InMetaData contain, among other things, the type of the input data. More specifically, InMetaData::type is a fusion map describing all the fields of the input data.
Given that you're using a map, I guess that the user has to define "dummy"
types as field names (unless he's satisfied with exactly one value for each
primitive type)?
Hm, a crazy question: what would happen if I decided to declare
map
typename result_of::join< InMetaData, CacheMetaData, IndexType
::type apply( const typename InMetaData::type &r ) { typename IndexType::value_type key_value = fusion::at_key< IndexType >( r ) ; return fusion::as_map( fusion::join( r, fusion::erase_key< IndexType >( cache_.lookup( key_value ) ) ) ) ; }
Given your explanation, I have several questions about this code: - the name apply -- is this function a part of some larger class, so the name is prescribed by some protocol? - You have CacheMetaData as template parameter, yet you do not use it -- you have an instance variable cache_ instead. Is this just for illustration purposes or some other reason? - the return statement prejudices "map" as implementation, i.e., the code does not look generic enough :-) is there some metafunction that could replace fusion::as_map with something more generic, in case the user would like to use e.g. vectors? ditto for erase_key? And now a perceived inconsistency within fusion itself -- vector is clearly a map from a set of integers [0..n-1] to types, yet it is not a model of associative sequence. I.e. after having read the documentation for erase_key, it turns out that for vectors one has to use erase(), but erase_key() for maps.. i'm not saying that it's good or bad, it just strikes me as weird. Could you please also write a simple example of composition of two elements? (I.e. how it would be used by the 'end-user' programmer?)
On the other hand if I work by ignoring what is not needed I need explicitly to tell what I'll copy to the output file which requires more work. In fact
Yes, the same reason occurred to me a bit later too.
something concrete which gives me a clear goal. I'll try to use fusion and MPL as much as possible and see how far I can go with them. At this point I
nice attitude :)
I hope this can be of some help.
Yes, it was helpful. Thank you.