Opened 15 years ago

Closed 14 years ago

#53 closed defect (fixed)

Constructor gslapi::vector(void)

Reported by: Peter Owned by: Jari Häkkinen
Priority: major Milestone: yat 0.2
Component: gslapi Version:
Keywords: Cc:

Description (last modified by Jari Häkkinen)

See also #42

In void constructor (also in matrix class) all internal pointers are set to null, and consequently calling (virtually) any member function of the class(es) results in Crash.

Constructor should behave in the same way as in STL: vector(size_t size=0, double value=0.0) thus a void construction should result in a vector of length zero and the following code should work vector x; cout << x.size(); and print a zero

Change History (5)

comment:1 Changed 14 years ago by Jari Häkkinen

Milestone: later0.2

comment:2 Changed 14 years ago by Peter

If I've got it right, GSL isn't supporting vectors with zero size, which imply neither do we (because we don't want stupid if statements everywhere, do we? ). The option could therefore to go to the smallest integer larger than zero (i.e. one) and have the following constructor:

explicit vector (const size_t n=1, const double init_value=0)

However, this is not what you expect. You expect the "void" constructor to create a vector of size zero. Therefore I suggest that we skip all that. What is it used for anyway? Creating empty vectors that can be passed in to functions and resized and filled up, well that could be done with "vector(1)" in my opinion.

comment:3 Changed 14 years ago by Peter

One solution could be to add member variable size_ used in function size(void). This would at least make the size function work with zero sized vectors (that still is a bunch of null pointers internally).

comment:4 Changed 14 years ago by Jari Häkkinen

Description: modified (diff)

comment:5 Changed 14 years ago by Peter

Resolution: fixed
Status: newclosed

(In [733]) fixes #53

Note: See TracTickets for help on using tickets.