Boost logo

Boost Users :

From: Fabio Fracassi (Fracassi_at_[hidden])
Date: 2004-12-21 13:41:24


Hello,

I am trying to use the operators.hpp templates to create the following
behaviour.

I have a templated class like this.

template <class T>
class example {}

now I want to do something like this:

example<SomeType> r;
example<SomeType> a;
example<AnotherType> b;

r = a * b

To write the multiplication manually I would have to write a function template

template <class T, class OtherT>
example<T> operator*(const example<T>& op1, const example<OtherT>& op2);

So, now my question is: How can this be done with operators.hpp?
Obviously ...

template <class T>
class example : boost::multiplicative2<example<T>, example<OtherT> > {

 template <OtherT> example<T>& operator*=(const example<OtherT>& op);
 template <OtherT> example<T>& operator/=(const example<OtherT>& op);
}

... won't work, since "OtherT" isn't defined at its first occurrence.
Is there a way to do what I intended, or do I have to write these operators
manually?

Thanks,

Fabio Fracassi


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