|
Boost : |
From: Ben FrantzDale (benfrantzdale_at_[hidden])
Date: 2007-01-22 11:37:37
Is there a generic way to to initialize to zero an object representing a
point in a linear space? I know the base types can be constructed like
int foo(0);
or
double bar(0);
but but if I have a three-vector class, I don't want to give it
Vector::Vector(double);
because Vector(2) makes no sense. (Should Vector(2) make the Vector (2, 0,
0) or the Vector (2, 2, 2)?) I also would rather have Vector() create three
uninitialized doubles rather than default-constructing (0,0,0).
I know SGI's extension of MonoidOperation concept has an identity_element
function to go with it (see http://www.sgi.com/tech/stl/MonoidOperation.html),
but that's not widely supported.
So, what's the best way to initialize a generic point in a linear space to
zero before, e.g., adding up a bunch of points?
Ben
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk