
"Brian McNamara" <lorgon@cc.gatech.edu> wrote in message news:20040225235607.GA1327@gaia3.cc.gatech.edu...
See, e.g. http://www.boost.org/libs/lambda/doc/ar01s06.html operator-tag representations as well as the logic that "when combining float and double, promote both to double" already exist somewhere in Boost (ask Joel or Jaakko, I dunno the details), so reuse those.
With Brian's suggestion in mind, the first part is gone, and the relevant code for the second part becomes: ============== using namespace boost::lambda; // Just to make the following easier to read template< template< typename _ > class DAT > struct promote_sum { typedef void tag; }; template< typename P, typename E=void > struct do_not { enum { value = false }; }; template< typename P > struct do_not< P, typename P::tag > { enum { value = true }; }; template< typename T1, typename T2, template< typename _ > class DAT > inline typename boost::disable_if_c< do_not< promote_sum< DAT > >::value, DAT< typename plain_return_type_2< arithmetic_action<plus_action>, T1,T2 >::type >
::type operator+( const DAT<T1>& a, const DAT<T2>& b ) { typedef DAT< typename plain_return_type_2< arithmetic_action<plus_action>, T1,T2 >::type > T;
return T( a ) + T( b ); } ============== The usage is not changed. The code still compiles by MSVC++ 7.1 though takes markedly longer :( (must be due a lot of declarations included from <boost/lambda/lambda.hpp>). So we reuse the mechanism, but cause a heavyweight dependency.... Since the BLL's tagging facility for aritmetic operators is so extensive, perhaps a better idea would be to parameterize promote***<> instead of using separate versions (promote_sum<>) for each operator? I.e. template <> struct promote_type< plus_action, MyDAT > {}; ...Max...