Boost logo

Boost :

From: Brian McNamara (lorgon_at_[hidden])
Date: 2004-02-26 03:28:09

On Wed, Feb 25, 2004 at 09:18:08PM -0600, Max Motovilov wrote:
> (well, obviously....). FWIW, here's what the "universal operator+" becomes
> then:
> template< typename T1, typename T2, template< typename _ > class DAT >
> inline
> typename boost::disable_if_c<
> do_not< promote_sum< DAT > >::value,
> DAT< typename boost::result_of_plus<T1,T2>::type >
> >::type operator+( const DAT<T1>& a, const DAT<T2>& b )
> {
> typedef DAT< typename boost::result_of_plus<T1,T2>::type > T;
> return T( a ) + T( b );
> }

Is there a way to avoid

   template<... template< typename _ > class DAT >

? While I don't know a class like this offhand, I can imagine a class
that's typically instantiated along the lines of


and it would be swell if the "DAT" technique generalized so that you
could specify that you wanted to DAT-ify


I haven't thought about it hard enough, but it seems like something
along the lines of changing it to

   template <class X, class Y>
   // enable_if both X and Y "isa" DAT (of the same kind)
   // based on specialization of result_xxx traits, deduce what was
   // called T1/T2 before
   operator+( const X& x, const Y& y ) { ... }

My hunch is that it's possible, but I'm not totally sure.

-Brian McNamara (lorgon_at_[hidden])

Boost list run by bdawes at, gregod at, cpdaniel at, john at