Need help understanding boost::operators::dividable
I'm sure the answer to this is out there somewhere, but I'm
having trouble finding it. (wearing flame-retardant clothes...)
I want to use boost::operators::field_operators to generate all
the mathematical operators to allow Vector/scalar arithmetic.
Everything works fine except for dividing scalars by vectors.
Class Vector looks like this:
class Vector
: public std::vector<double>,
boost::field_operators
on Thu Jun 21 2007, "Scott, Steven"
w = v/x; // works fine w = x/v; // fails…
I think the failure happens because of the way operator/ defined for mixed types something like this:
T operator/(U u,T t) { T ans(u); ans/=t; return ans; }
which is not what I need. Is there a way I can change the way operator/(double,Vector) works in this one case, but keep the really convenient definitions generated by field_operators otherwise?
Are you sure you want that? I don't think it's meaningful to divide a scalar by a vector. What would the result be? Anyway, if you really do want that, the easy thing to do is add the definition of the overload you want to your class in the usual manual way. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com
participants (2)
-
David Abrahams
-
Scott, Steven