$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Torsten Maehne (Torsten.Maehne_at_[hidden])
Date: 2008-06-06 09:51:54
Hello Steven,
thank you for helping me in debugging lambda.hpp!
Steven Watanabe wrote:
> AMDG
> 
> Torsten Maehne wrote:
>>>> * All checks involving the multiplication/division of
>>>>   boost::units::unit and boost::units::absolute<boost::units::unit>
>>>>   types are not compiling. The compiler complains about ambiguous
>>>>   overloads for operator* and operator/ (originating from Boost.Units
>>>>   and Boost.Lambda). Therefore they are currently commented out.
>>>>   
>>>>       
>>> These shouldn't compile.
>>>     
>> I modified the checks so that now units and absolute units are passed as
>> well as arguments to the lambda expressions. Then the ambiguous overload
>> errors disappear. However, for the absolute unit tests:
>> <snip>
>>
>> I left the non-compiling commented-out tests in place for documentation
>> purposes.
>>   
> 
> I looked at the tests.  I misunderstood what you were testing.
> Allowing multiplication _1 * meters e.g. would require disambiguating 
> overloads.
I have tried to add specializations to lambda.hpp like the following:
    /// Partial specialization of return type trait for action
    /// boost::lambda::functor<T> * unit<Dim, System>.
    template<typename System, typename Dim, typename T>
    struct plain_return_type_2<arithmetic_action<multiply_action>,
                               boost::lambda::lambda_functor<T>,
                               boost::units::unit<Dim, System> > {
        typedef typename boost::units::multiply_typeof_helper<
            boost::lambda::lambda_functor<T>,
            boost::units::unit<Dim, System> >::type type;
    };
, to disambiguate the overloads. However the specialization seems to be
not picked up by the compiler -- it still uses either:
boost::lambda::functor<T> * Y
or
Y * unit<Dim, System>
when uncommenting the check for bl::_1 * bu::meters in test_lambda.cpp.
(Note: I didn't add the specialization to the attached corrected
lambda.hpp.) Do you have an idea, what I'm doing wrong here?
>>>> * The check of unit<Dim1, System1> - unit<Dim2, System2> is not
>>>>   compiling. The compiler finds no matching definition of operator-.
>>>>   
>>>>       
>>> Again these shouldn't compile.
>>>     
>> This strikes me as being inconsistent, because it works for:
>>
>> unit<Dim1, System1> + unit<Dim2, System2>
>>   
> 
> I see.  I didn't understand what you were testing, again.
> The problem is in units/lambda.hpp line 390 ff.
> 
>     /// Partial specialization of return type trait for action
>     /// unit<Dim1, System1> - unit<Dim2, System2>.
>     template<typename Dim1, typename Dim2, typename System1, typename 
> System2>
>     struct plain_return_type_2<arithmetic_action<minus_action>,
>                                boost::units::unit<Dim1, System1>,
>                                boost::units::unit<Dim2, System2> > {
>         BOOST_STATIC_ASSERT((boost::is_same<System1, System2>::value == 
> true));
>         typedef typename boost::units::subtract_typeof_helper<
>             boost::units::*quantity*<Dim1, System1>,
>             boost::units::*quantity*<Dim2, System2> >::type type;
>     };
> 
> These two quantities ought to be units.
Thanks for pointing me to this nasty copy & paste error. I corrected it
in the attached new lambda.hpp.
Best regards,
Torsten