
On Jun 4, 5:55 pm, alfC <alfredo.cor...@gmail.com> wrote:
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; };
Actually (unfortunately) it seems that all 4 combinations of reference/ no reference are needed. This is the only way I managed to make these expression work with type deduction: arg1*arg1 (arg1*arg1)*arg1 arg1*(arg1*arg1) (arg1*arg1)*(arg1*arg1) So, I have to implement this kind of macro sorcery to bridge Boost.Units and Boost.Phoenix. Not sure if I will find another bump in the road: namespace boost{ namespace phoenix{ using namespace boost::units; #define RESULT_OF_GEN( PhoenixnamE, UnitsnamE, RefQ1, RefQ2 ) \ template<class XUnit, class YUnit, class TX, class TY> \ struct result_of_##PhoenixnamE <quantity<XUnit,TX> RefQ1, quantity<YUnit,TY> RefQ2>{ \ typedef typename UnitsnamE##_typeof_helper<quantity<XUnit,TX>&,quantity<YUnit,TY>&
::type type; \ }; RESULT_OF_GEN(multiplies, multiply, &, ) RESULT_OF_GEN(multiplies, multiply, &, &) RESULT_OF_GEN(multiplies, multiply, , ) RESULT_OF_GEN(multiplies, multiply, , &) RESULT_OF_GEN(divides , divide , &, ) RESULT_OF_GEN(divides , divide , &, &) RESULT_OF_GEN(divides , divide , , ) RESULT_OF_GEN(divides , divide , , &) #undef RESULT_OF_GEN }}