comparison liboctave/dim-vector.cc @ 10830:b4ebfd675321

avoid static initialization disaster in dim_vector
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 29 Jul 2010 08:47:26 +0200
parents 6683f0c9d742
children fd0a3ac60b0e
comparison
equal deleted inserted replaced
10829:61cb53ae9db3 10830:b4ebfd675321
31 31
32 // The maximum allowed value for a dimension extent. This will normally be a tiny bit 32 // The maximum allowed value for a dimension extent. This will normally be a tiny bit
33 // off the maximum value of octave_idx_type. 33 // off the maximum value of octave_idx_type.
34 // Currently 1 is subtracted to allow safe conversion of any 2D Array into Sparse, 34 // Currently 1 is subtracted to allow safe conversion of any 2D Array into Sparse,
35 // but this offset may change in the future. 35 // but this offset may change in the future.
36 const octave_idx_type 36 octave_idx_type
37 dim_vector::dim_max = std::numeric_limits<octave_idx_type>::max () - 1; 37 dim_vector::dim_max (void)
38 {
39 return std::numeric_limits<octave_idx_type>::max () - 1;
40 }
38 41
39 void 42 void
40 dim_vector::chop_all_singletons (void) 43 dim_vector::chop_all_singletons (void)
41 { 44 {
42 make_unique (); 45 make_unique ();
87 } 90 }
88 91
89 octave_idx_type 92 octave_idx_type
90 dim_vector::safe_numel (void) const 93 dim_vector::safe_numel (void) const
91 { 94 {
92 octave_idx_type idx_max = dim_max; 95 octave_idx_type idx_max = dim_max ();
93 octave_idx_type n = 1; 96 octave_idx_type n = 1;
94 int n_dims = length (); 97 int n_dims = length ();
95 98
96 for (int i = 0; i < n_dims; i++) 99 for (int i = 0; i < n_dims; i++)
97 { 100 {