Boost logo

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);
  double bar(0);
but but if I have a three-vector class, I don't want to give it
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,
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?


Boost list run by bdawes at, gregod at, cpdaniel at, john at