|
Boost Users : |
From: Andy Little (andy_at_[hidden])
Date: 2006-05-04 03:26:04
"Pedro Lamarão" wrote
> I would like to see some "motivating example", like this one from the
> MPL documentation:
>
> http://www.boost.org/libs/mpl/doc/tutorial/tutorial-metafunctions.html
If the above is a motivating example for mpl, then I dont think it is the best
one. The problem is even highlighted in:
http://www.boost.org/libs/mpl/doc/tutorial/implementing.html
At the point in the text where it says;
"
However, if we try to write:
quantity<float,force> f = m * a;
we'll run into a little problem.
".
The problem is that mpl doesnt work as the (naive?) user expects, but worse the
actual type of the quantity resulting from a multiplication isnt exactly
defined. All that is known about it is that its dimension is comprised of "some
sequence". In practise I found this, which was described as a convenience
feature actually caused a great deal more work in the implementation. It also
causes problems with trying to figure what to register with Boost.Typeof and I
suspect that it would continue to throw up similar problems whenever the type is
required to be known. The fact is that an interface must have exactly
predictable types. The interface in this case ( The visible part. e.g for use in
function signatures etc) is in the template signature of the class. IMO mpl isnt
the best way to implement the dimension of a quantity for this reason.
I am sorry to go on about this, but I am expecting to have a boost review of my
pqs library shortly and the issue is bound to come up. I suspect that the fact
that it doesnt use mpl will be seen by the naive ( in the same sense as used
above) user as a shortcoming of pqs. I believe that for this useage the
shortcoming is rather in mpl for this particular useage, which the above
example demonstrates.
regards
Andy Little
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net