Boost logo

Boost Users :

From: Malte Clasen (news_at_[hidden])
Date: 2005-10-16 14:53:19


Hi,

the book "C++ Template Metaprogramming" by Abrahams and Gurtovoy
describes a dimensional analyis framework that enables compile-time
checking of physical units. For example dividing a length quantity by a
time quantity results in a speed quantity.

Now it's tempting to use boost uBLAS with these quantities: A position
in space can be expressed as a vector of length quantities etc. But
there's one problem:

"// uBLAS assumes a common return type for all binary arithmetic operators"
(traits.hpp, line 42, boost release 1.33)

The promote_traits class relies on this when computing the following:

static const std::size_t size = sizeof (
     type_deduction_detail::test<
         typename base_type::x_type
         , typename base_type::y_type
>(x + y) // Use x+y to stand of all the arithmetic actions
     );

This fails for most quantity operations since dividing a length by a
length results in a different type than adding them. As a result Visual
C++ 7.1 complains about not being able to deduce template arguments.

Is there a way to fix this? I'm not that familiar with the internals of
uBLAS, I don't even know the purpose of promote_traits.

     Malte


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