Boost logo

Boost Users :

Subject: Re: [Boost-users] [phoenix][units] make boost.phoenix play well with boost.units
From: Joel de Guzman (joel_at_[hidden])
Date: 2010-06-04 20:07:28


On 6/5/10 6:01 AM, alfC wrote:
> On Jun 3, 7:52 pm, Joel de Guzman<j..._at_[hidden]> wrote:
>> > On 6/4/10 10:31 AM, alfC wrote:
>> > There is hope. Just specialize boost::phoenix::result_of_xxx
>> > (e.g. boost::phoenix::result_of_plus<X, Y>).
> I specilized result_of_multiplies and still no luck:
>
> #include<boost/spirit/home/phoenix.hpp>
> #include<iostream>
> #include<typeinfo>
> #include<boost/units/systems/si.hpp>
>
> namespace boost{
> namespace phoenix{
> using namespace boost::units;
> template<> //in general template<class XUnit, class YUnit>
> struct result_of_multiplies<quantity<si::length>, quantity<si::length>
>> >{
> typedef quantity<si::area> type;
> };
> }}

The type-deduction respects references. Phoenix2 passes in references.
The code should be:

     template<> //in general template<class XUnit, class YUnit>
     struct result_of_multiplies<quantity<si::length>&, quantity<si::length>&>
     {
         typedef quantity<si::area> type;
     };

Regards,

-- 
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net

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