
Boost : 
From: Ben FrantzDale (benfrantzdale_at_[hidden])
Date: 20070122 12:15:10
Paul,
That isn't quite what I have in mind. (I asked on this list since it seemed
most likely that Boost would have solved this problem if anyone has.)
In the case of Vector, I would like to have Vector() create uninitialized
memory because then Vector x[1000] takes essentially no time. But efficiency
aside, the question is really how can I generically initialize a point in a
linear space to the zero of that linear space.
It would be nice if there were an agreedupon PointInALinearSpace concept
with a standard way of creating the zero element. One way would be to make a
special zero type so then I could have these two consctructors:
Vector::Vector() {} // Uninitialized members.
Vector::Vector(const Zero<Vector>&) : x(0), y(0), z(0) {}
—Ben
On 1/22/07, Paul Giaccone <paulg_at_[hidden]> wrote:
>
> Ben FrantzDale wrote:
> > 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 threevector 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
> >
>
> This is really a C++ question rather than a Boost one, if I have
> understood it correctly.
>
> I usually use an unparameterised constructor for this, and, indeed,
> there is one in the code I am working on right now:
>
> Vector::Vector(void) : x(0.0), y(0.0), z(0,0)
> {
> //any other stuff here
> }
>
>
> Does this do what you want?
>
> Paul
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk