help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Allocating N-dimensional Array in C++


From: John W. Eaton
Subject: Re: Allocating N-dimensional Array in C++
Date: Thu, 18 Mar 2010 16:41:55 -0400

On 17-Mar-2010, Jaroslav Hajek wrote:

| I supplied some generic macro magic for such tasks, then did it like this:
| 
| #define ASSIGN_REP(i) rep[i] = d ## i;
| #define DIM_VECTOR_CTOR(N) \
|   dim_vector (OCT_MAKE_DECL_LIST(octave_idx_type, d, N)) \
|     : rep (newrep (N)) \
|   { \
|     OCT_ITERATE_MACRO(ASSIGN_REP, N) \
|   }
| 
|   // Add more if needed.
|   DIM_VECTOR_CTOR(4)
|   DIM_VECTOR_CTOR(5)
|   DIM_VECTOR_CTOR(6)
|   DIM_VECTOR_CTOR(7)
| 
| #undef ASSIGN_REP
| #undef DIM_VECTOR_CTOR

Any objection to removing the

  dim_vector (const octave_idx_type *vec, size_t vec_size)

construtor?  Or is there some big advantage to having this constructor
that outweighs the negatives of it being an unsafe constructor since
there is no way to ensure that the length of the array pointed to by
VEC is at least VEC_SIZE elements?

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]