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
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 {
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