|
Boost : |
From: Andreas Pokorny (andreas.pokorny_at_[hidden])
Date: 2005-12-02 14:25:49
Hi,
The default implementation of boost::fusion::pair<first,second> only stores
an instance of second. I might need a fusion::pair which does not store
that instance either, maybe that will cause trouble in several parts of
fusion. At first I would like to explain what I am doing right now. At
the moment I do work on an expression template framework, similiar to
Eric Nieblers boost::proto, which was used to build boost::xpressive.
I do extend that library by adding a rule system which enables the user
to define the allowed operations of a certain domain. To simplify and
generalize the rule writing process, every node in the expression tree
has a fusion::map<> which is supposed to hold some meta information.
E.g. in the matrix vector domain, that attribute container of a binary
node returned by binary plus, might look like that:
map< pair<domain_tag, linear_algebra_domain>
, pair<operator_tag, plus_tag>
, pair<category_tag, column_vector_tag>
, pair<dimension_tag, dynamic::dimension>
, pair<element_type_tag, float>
>
There are entries in the map that do not require runtime data at all,
for these entries all information is coverd by the second template
parameter of pair. And others like the dimension_tag which require
an instance of the second type stored in the container.
How can I acchieve that with fusion?
I thougt about a rather ugly solution:
template <typename T>
struct ct{ typedef T type };
map< pair<domain_tag, ct<linear_algebra_domain> >
, pair<operator_tag, ct<plus_tag> >
, pair<category_tag, ct<column_vector_tag> >
, pair<dimension_tag, dynamic::dimension>
, pair<element_type_tag, ct<float> >
>
Then only an empty ct is stored.
The main reason for all this is the element_type_tag. It should be
possible to define a matrix with some matrix type as element_type.
Regards,
Andreas Pokorny
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk