Boost logo

Glas :

Re: [glas] proposals

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2007-02-05 05:50:54


Hi Karl,

On Monday 05 February 2007 11:02, Karl Meerbergen wrote:
> A) Use meta programming to examine an expression.
> For each type, we can ask questions about where we are in the concept
> tree. In the above example,

> B) Use Bartan-Nackman trick

Before I start: Is there an automatic tool, that can convert code for
conceptc++ to concept-free c++ code? (Such that conceptc++ works as a kind of
preprocessor for g++?)

About your proposals: I generally don't like the Barton-Nackman trick (CRTP).
This caused always headache when I tried to figure out the right combinations
of parameters for my functions. A good example of this is the various
dispatch mechanisms of ublas, which are hard to follow. So I would always
prefer a solution which is readable.
Thus I prefer a (single) dispatch with some meta-programming and function
parameters that show what they are:

(correct me, if I am wrong) the CRTP versions would look like:
do_something(vector_expression<V> & v, scalar_expression<S> & s, ...,
dense_tag, ...);
do_something(vector_expression<V> & v, scalar_expression<S> & s, ...,
unknown_tag, ...);

the A) version just would look like
do_something(V & v, S & s,
  is_convertible< concept_tag<V>::type, dense_vector_expression_tag >,
  is_convertible< concept_tag<V>::type, scalar_expression_tag > );
...

IMO the possibility to easily add custom class and custom algorithms for
expression is quite important.
Finally, the best solution would be to only need the concepts ...

mfg
Gunter