help with boost/numeric/operators.hpp

I'm haveing some problems figuring out how to use boost/numeric/operators
library.
OK - I understand how to use
template<class T>
struct my_type : boost::numeric::operators<T> {
T & operator+=(T & rhs);
// automatically generate operator+, etc
// ...
};
so that one can use
my_type<int> x, y, z;
z = x + y;
// etc..
There is a simple example like this in the documentation. So far so good.
Now given:
int & operator+=(int & lhs, my_type<int>);
I want to use operators

Robert Ramey
template<class T> struct my_type : boost::numeric::operators<T> { T & operator+=(T & rhs); // automatically generate operator+, etc // ... };
so that one can use my_type<int> x, y, z; z = x + y; // etc..
I'm not familiar with boost::numeric::operators<T> but I have used
Boost.Operators to do similar. In this case I'd write:
template<typename T>
struct my_type : boost::addable
There is a simple example like this in the documentation. So far so good.
Now given:
int & operator+=(int & lhs, my_type<int>);
I want to use operators
to generate int operator+(int & lhs, my_type<int>);
If you want that exact return value ("int" not "my_type<int>") then I suppose
you've defined the proper operator+= overload for it and just need that
visible and to modify my_type as follows:
template<typename T>
struct my_type : boost::addable
participants (2)
-
Robert Ramey
-
Ryan Gallagher