plll  1.0
matrix-mem.hpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2011-2014 University of Zurich
3 
4  Permission is hereby granted, free of charge, to any person obtaining a copy
5  of this software and associated documentation files (the "Software"), to deal
6  in the Software without restriction, including without limitation the rights
7  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  copies of the Software, and to permit persons to whom the Software is
9  furnished to do so, subject to the following conditions:
10 
11  The above copyright notice and this permission notice shall be included in
12  all copies or substantial portions of the Software.
13 
14  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  THE SOFTWARE.
21 */
22 
23 #ifndef PLLL_INCLUDE_GUARD__MATRIX_MEM_HPP
24 #define PLLL_INCLUDE_GUARD__MATRIX_MEM_HPP
25 
26 #include <cassert>
27 #include <cstddef>
28 #include <cstdlib>
29 //#include <iostream>
30 
31 #if __cplusplus >= 201103L
32  #include <utility>
33 #endif
34 
54 namespace plll
55 {
56  namespace linalg
57  {
59  // Memory management
60 
61  //#define __VECMAT_MM_DEBUG
62  //#define __VECMAT_MM_FAILSAFE
63  #define __VECMAT_MM_RELEASE
64 
65  #ifdef __VECMAT_MM_DEBUG
66 
67  #define __VECMAT_MM_DEBUG__BEGIN_OK 0xAFFE1234
68  #define __VECMAT_MM_DEBUG__END_OK 0x1234AFFE
69  #define __VECMAT_MM_DEBUG__BEGIN_REL 0xF8E8F8E8
70  #define __VECMAT_MM_DEBUG__END_REL 0x1E1F1E1F
71  #define __VECMAT_MM_DEBUG__DEAD 0xDEADBEEF
72 
73  template<class T>
74  class storage_traits
75  {
76  private:
77  enum { DEBUG_PAD_BEGIN = 4,
78  DEBUG_PAD_END = 4 };
79 
80  static T * create(unsigned int n, bool dontconstruct)
81  {
82  unsigned SIZE = ((n * sizeof(T) + 3) & (unsigned)(~3));
83  assert(SIZE >= n * sizeof(T));
84  char * realptr = reinterpret_cast<char *>(malloc(SIZE + (DEBUG_PAD_BEGIN + DEBUG_PAD_END) * 4));
85  char * realptrend = realptr + SIZE + DEBUG_PAD_BEGIN * 4;
86  for (int i = 0; i < DEBUG_PAD_BEGIN; ++i)
87  ((unsigned int*)realptr)[i] = __VECMAT_MM_DEBUG__BEGIN_OK;
88  for (int i = 0; i < DEBUG_PAD_END; ++i)
89  ((unsigned int*)realptrend)[i] = __VECMAT_MM_DEBUG__END_OK;
90  T * ptr = reinterpret_cast<T*>(realptr + DEBUG_PAD_BEGIN * 4);
91 // std::cout << "ALC: " << (void*)realptr << " " << (void*)ptr << " " << sizeof(T) << " x " << n << " " << (void*)realptrend << "\n";
92  if (!dontconstruct)
93  for (unsigned i = 0; i < n; ++i)
94  ::new(static_cast<void *>(ptr + i)) T();
95  for (int i = 0; i < DEBUG_PAD_BEGIN; ++i)
96  assert(((unsigned int*)realptr)[i] == __VECMAT_MM_DEBUG__BEGIN_OK);
97  for (int i = 0; i < DEBUG_PAD_END; ++i)
98  assert(((unsigned int*)realptrend)[i] == __VECMAT_MM_DEBUG__END_OK);
99  return ptr;
100  }
101 
102  static void release(T * ptr, unsigned int n)
103  {
104  if (ptr == 0)
105  {
106  assert(n == 0);
107  return;
108  }
109  unsigned SIZE = ((n * sizeof(T) + 3) & (unsigned)(~3));
110  char * realptr = reinterpret_cast<char *>(ptr) - DEBUG_PAD_BEGIN * 4;
111  char * realptrend = realptr + SIZE + DEBUG_PAD_BEGIN * 4;
112 // std::cout << "REL: " << (void*)realptr << " " << (void*)ptr << " " << sizeof(T) << " x " << n << " " << (void*)realptrend << "\n";
113  for (int i = 0; i < DEBUG_PAD_BEGIN; ++i)
114  assert(((unsigned int*)realptr)[i] == __VECMAT_MM_DEBUG__BEGIN_OK);
115  for (int i = 0; i < DEBUG_PAD_END; ++i)
116  assert(((unsigned int*)realptrend)[i] == __VECMAT_MM_DEBUG__END_OK);
117  // Deconstruct
118  for (unsigned i = 0; i < n; ++i)
119  (ptr + i)->~T();
120  // Fill with __VECMAT_MM_DEBUG__DEAD
121  for (unsigned i = 0; i < n * sizeof(T) / 4; ++i)
122  (reinterpret_cast<unsigned int*>(ptr))[i] = __VECMAT_MM_DEBUG__DEAD;
123  // Check padding and stop
124  for (int i = 0; i < DEBUG_PAD_BEGIN; ++i)
125  {
126  assert((reinterpret_cast<unsigned int*>(realptr))[i] == __VECMAT_MM_DEBUG__BEGIN_OK);
127  (reinterpret_cast<unsigned int*>(realptr))[i] = __VECMAT_MM_DEBUG__BEGIN_REL;
128  }
129  for (int i = 0; i < DEBUG_PAD_END; ++i)
130  {
131  assert((reinterpret_cast<unsigned int*>(realptrend))[i] == __VECMAT_MM_DEBUG__END_OK);
132  (reinterpret_cast<unsigned int*>(realptrend))[i] = __VECMAT_MM_DEBUG__END_REL;
133  }
134  ::free(realptr);
135  }
136 
137  public:
138  static void check(T * ptr, unsigned int n)
139  {
140  if (ptr == 0)
141  {
142  assert(n == 0);
143  return;
144  }
145  unsigned SIZE = ((n * sizeof(T) + 3) & (unsigned)(~3));
146  char * realptr = reinterpret_cast<char *>(ptr) - DEBUG_PAD_BEGIN * 4;
147  char * realptrend = realptr + SIZE + DEBUG_PAD_BEGIN * 4;
148 // std::cout << "CHK: " << (void*)realptr << " " << (void*)ptr << " " << sizeof(T) << "x" << n << "=" << SIZE << " " << (void*)realptrend << "\n";
149  for (int i = 0; i < DEBUG_PAD_BEGIN; ++i)
150  assert((reinterpret_cast<unsigned int*>(realptr))[i] == __VECMAT_MM_DEBUG__BEGIN_OK);
151  for (int i = 0; i < DEBUG_PAD_END; ++i)
152  assert((reinterpret_cast<unsigned int*>(realptrend))[i] == __VECMAT_MM_DEBUG__END_OK);
153  }
154 
155  typedef T * pointer_type;
156  typedef const T * constpointer_type;
157  typedef T & ref_type;
158  typedef const T & constref_type;
159 
160  static void construct(ref_type ref)
161  // Constructs an object via default constructor.
162  {
163  ::new(static_cast<void *>(&ref)) T();
164  }
165 
166  template<class S>
167  static void copy_construct(ref_type ref, const S & obj)
168  // Constructs an object via copy constructor.
169  {
170  ::new(static_cast<void *>(&ref)) T(obj);
171  }
172 
173 #if __cplusplus >= 201103L
174  template<class S>
175  static void move_construct(ref_type ref, S && obj)
176  // Constructs an object via move constructor.
177  {
178  ::new(static_cast<void *>(&ref)) T(std::move(obj));
179  }
180 #endif
181 
182  static pointer_type alloc(unsigned int n)
183  // Creates an array of n elements of type T. The entries are created using the default
184  // constructor.
185  {
186  pointer_type newptr = create(n, false);
187 // std::cout << "[#:" << newptr << "] Creating array of " << n << " elements of type " << typeid(T).name() << "\n";
188  return newptr;
189  }
190 
191  static pointer_type alloc_dontconstruct(unsigned int n)
192  // Creates an array of n elements of type T. The entries are not constructed.
193  {
194  pointer_type newptr = create(n, true);
195 // std::cout << "[#:" << newptr << "] Creating array of " << n << " elements of type " << typeid(T).name() << "\n";
196  return newptr;
197  }
198 
199  template<class S>
200  static pointer_type alloc(const S & obj, unsigned int n)
201  // Creates an array of n elements of type T, all being copies of obj (of type S).
202  {
203  pointer_type newptr = create(n, true);
204 // std::cout << "[#:" << newptr << "] Creating array of " << n << " elements of type " << typeid(T).name() << ", constructed from object [" << &obj << "].\n";
205  for (unsigned i = 0; i < n; ++i)
206  copy_construct(newptr[i], obj);
207  return newptr;
208  }
209 
210  template<class S>
211  static pointer_type clone(S * ptr, unsigned int n)
212  // Creates an array of n elements of type T. The entries are copy-constructed from the given
213  // array ptr (of type S).
214  {
215  pointer_type newptr = create(n, true);
216 // std::cout << "[#:" << newptr << "] Cloning array of " << n << " elements of type " << typeid(T).name() << " [" << ptr << "].\n";
217  for (unsigned i = 0; i < n; ++i)
218  copy_construct(newptr[i], ptr[i]);
219  return newptr;
220  }
221 
222  template<class S>
223  static pointer_type clone(S * ptr, unsigned int n, unsigned int ncopy)
224  // Creates an array of n elements of type T. The first ncopy elements are copy-constructed from
225  // the given array ptr, the last ones are constructed with the default constructor.
226  {
227  pointer_type newptr = create(n, true);
228 // std::cout << "[#:" << newptr << "] Cloning array of " << n << " elements of type " << typeid(T).name() << " (only the " << ncopy << " first) [" << ptr << "].\n";
229  for (unsigned i = 0; i < ncopy; ++i)
230  copy_construct(newptr[i], ptr[i]);
231  for (unsigned i = ncopy; i < n; ++i)
232  construct(newptr[i]);
233  return newptr;
234  }
235 
236  template<class S, class SS>
237  static pointer_type clone(S * ptr, unsigned int n, unsigned int ncopy, const SS & copyobj)
238  // Creates an array of n elements of type T. The first ncopy elements are copy-constructed from
239  // the given array ptr, the last ones are constructed with the default constructor.
240  {
241  pointer_type newptr = create(n, true);
242 // std::cout << "[#:" << newptr << "] Cloning array of " << n << " elements of type " << typeid(T).name() << " (only the " << ncopy << " first) [" << ptr << "].\n";
243  for (unsigned i = 0; i < ncopy; ++i)
244  copy_construct(newptr[i], ptr[i]);
245  for (unsigned i = ncopy; i < n; ++i)
246  construct(newptr[i]);
247  return newptr;
248  }
249 
250 #if __cplusplus >= 201103L
251  template<class S>
252  static pointer_type clone_move(S * ptr, unsigned int n)
253  // Creates an array of n elements of type T. The entries are copy-constructed from the given
254  // array ptr (of type S).
255  {
256  pointer_type newptr = create(n, true);
257 // std::cout << "[#:" << newptr << "] Cloning array of " << n << " elements of type " << typeid(T).name() << " [" << ptr << "].\n";
258  for (unsigned i = 0; i < n; ++i)
259  copy_construct(newptr[i], std::move(ptr[i]));
260  return newptr;
261  }
262 
263  template<class S>
264  static pointer_type clone_move(S * ptr, unsigned int n, unsigned int ncopy)
265  // Creates an array of n elements of type T. The first ncopy elements are copy-constructed from
266  // the given array ptr, the last ones are constructed with the default constructor.
267  {
268  pointer_type newptr = create(n, true);
269 // std::cout << "[#:" << newptr << "] Cloning array of " << n << " elements of type " << typeid(T).name() << " (only the " << ncopy << " first) [" << ptr << "].\n";
270  for (unsigned i = 0; i < ncopy; ++i)
271  copy_construct(newptr[i], std::move(ptr[i]));
272  for (unsigned i = ncopy; i < n; ++i)
273  construct(newptr[i]);
274  return newptr;
275  }
276 
277  template<class S, class SS>
278  static pointer_type clone_move(S * ptr, unsigned int n, unsigned int ncopy, const & SS copyobj)
279  // Creates an array of n elements of type T. The first ncopy elements are copy-constructed from
280  // the given array ptr, the last ones are constructed with the default constructor.
281  {
282  pointer_type newptr = create(n, true);
283 // std::cout << "[#:" << newptr << "] Cloning array of " << n << " elements of type " << typeid(T).name() << " (only the " << ncopy << " first) [" << ptr << "].\n";
284  for (unsigned i = 0; i < ncopy; ++i)
285  copy_construct(newptr[i], std::move(ptr[i]));
286  for (unsigned i = ncopy; i < n; ++i)
287  construct(newptr[i]);
288  return newptr;
289  }
290 #endif
291 
292  static void free(pointer_type ptr, unsigned int n)
293  // Destroys an array of n elements of type T.
294  {
295 // std::cout << "[#:" << ptr << "] Releasing array of " << n << " elements of type " << typeid(T).name() << ".\n";
296  release(ptr, n);
297  }
298  };
299 
300  #endif
301 
302  #ifdef __VECMAT_MM_FAILSAFE
303 
304  template<class T>
305  class storage_traits
306  {
307  public:
308  typedef T * pointer_type;
309  typedef T & ref_type;
310  typedef const T * constpointer_type;
311  typedef const T & constref_type;
312 
313  static void construct(ref_type ref)
314  // Constructs an object via default constructor.
315  {
316  ::new(static_cast<void *>(&ref)) T();
317  }
318 
319  template<class S>
320  static void copy_construct(ref_type ref, const S & obj)
321  // Constructs an object via copy constructor.
322  {
323  ::new(static_cast<void *>(&ref)) T(obj);
324  }
325 
326 #if __cplusplus >= 201103L
327  template<class S>
328  static void move_construct(ref_type ref, S && obj)
329  // Constructs an object via move constructor.
330  {
331  ::new(static_cast<void *>(&ref)) T(std::move(obj));
332  }
333 #endif
334 
335  static pointer_type alloc(unsigned int n)
336  // Creates an array of n elements of type T. The entries are created using the default
337  // constructor.
338  {
339  return new T[n];
340  }
341 
342  static pointer_type alloc_dontconstruct(unsigned int n)
343  // Creates an array of n elements of type T. The entries are not constructed.
344  {
345  return reinterpret_cast<pointer_type>(::operator new(sizeof(T) * n));
346  }
347 
348  template<class S>
349  static pointer_type alloc(const S & obj, unsigned int n)
350  // Creates an array of n elements of type T, all being copies of obj (of type S).
351  {
352  pointer_type newptr = new T[n];
353  for (unsigned i = 0; i < n; ++i)
354  newptr[i] = obj;
355  return newptr;
356  }
357 
358  template<class S>
359  static pointer_type clone(S * ptr, unsigned int n)
360  // Creates an array of n elements of type T. The entries are copy-constructed from the given
361  // array ptr (of type S).
362  {
363  pointer_type newptr = new T[n];
364  for (unsigned i = 0; i < n; ++i)
365  newptr[i] = ptr[i];
366  return newptr;
367  }
368 
369  template<class S>
370  static pointer_type clone(S * ptr, unsigned int n, unsigned int ncopy)
371  // Creates an array of n elements of type T. The first ncopy elements are copy-constructed from
372  // the given array ptr, the last ones are constructed with the default constructor.
373  {
374  pointer_type newptr = new T[n];
375  for (unsigned i = 0; i < ncopy; ++i)
376  newptr[i] = ptr[i];
377  return newptr;
378  }
379 
380  template<class S, class SS>
381  static pointer_type clone(S * ptr, unsigned int n, unsigned int ncopy, const SS & copyobj)
382  // Creates an array of n elements of type T. The first ncopy elements are copy-constructed from
383  // the given array ptr, the last ones are constructed with the default constructor.
384  {
385  pointer_type newptr = new T[n];
386  for (unsigned i = 0; i < ncopy; ++i)
387  newptr[i] = ptr[i];
388  for (unsigned i = ncopy; i < n; ++i)
389  newptr[i] = copyobj;
390  return newptr;
391  }
392 
393 #if __cplusplus >= 201103L
394  template<class S>
395  static pointer_type clone_move(S * ptr, unsigned int n)
396  // Creates an array of n elements of type T. The entries are copy-constructed from the given
397  // array ptr (of type S).
398  {
399  pointer_type newptr = new T[n];
400  for (unsigned i = 0; i < n; ++i)
401  newptr[i] = std::move(ptr[i]);
402  return newptr;
403  }
404 
405  template<class S>
406  static pointer_type clone_move(S * ptr, unsigned int n, unsigned int ncopy)
407  // Creates an array of n elements of type T. The first ncopy elements are copy-constructed from
408  // the given array ptr, the last ones are constructed with the default constructor.
409  {
410  pointer_type newptr = new T[n];
411  for (unsigned i = 0; i < ncopy; ++i)
412  newptr[i] = std::move(ptr[i]);
413  return newptr;
414  }
415 
416  template<class S, class SS>
417  static pointer_type clone_move(S * ptr, unsigned int n, unsigned int ncopy, const SS & copyobj)
418  // Creates an array of n elements of type T. The first ncopy elements are copy-constructed from
419  // the given array ptr, the last ones are constructed with the default constructor.
420  {
421  pointer_type newptr = new T[n];
422  for (unsigned i = 0; i < ncopy; ++i)
423  newptr[i] = std::move(ptr[i]);
424  for (unsigned i = ncopy; i < n; ++i)
425  newptr[i] = copyobj;
426  return newptr;
427  }
428 #endif
429 
430  static void free(pointer_type ptr, unsigned int n)
431  // Destroys an array of n elements of type T.
432  {
433  delete[] ptr;
434  }
435 
436  inline static void check(pointer_type ptr, unsigned int n)
437  {
438  }
439  };
440 
441  #endif
442 
443  #ifdef __VECMAT_MM_RELEASE
444 
445  template<class T>
451  {
452  public:
453  typedef T * pointer_type;
454  typedef T & ref_type;
455  typedef const T * constpointer_type;
456  typedef const T & constref_type;
457 
458  static void construct(ref_type ref)
460  {
461  ::new(static_cast<void *>(&ref)) T();
462  }
463 
464  template<class S>
465  static void copy_construct(ref_type ref, const S & obj)
467  {
468  ::new(static_cast<void *>(&ref)) T(obj);
469  }
470 
471 #if __cplusplus >= 201103L
472  template<class S>
473  static void move_construct(ref_type ref, S && obj)
475  {
476  ::new(static_cast<void *>(&ref)) T(std::move(obj));
477  }
478 #endif
479 
480  static pointer_type alloc(unsigned int n)
483  {
484  if (n == 0)
485  return NULL;
486  pointer_type newptr = reinterpret_cast<pointer_type>(::operator new(sizeof(T) * n));
487  for (unsigned i = 0; i < n; ++i)
488  ::new(static_cast<void *>(newptr + i)) T();
489  return newptr;
490  }
491 
492  static pointer_type alloc_dontconstruct(unsigned int n)
495  {
496  if (n == 0)
497  return NULL;
498  pointer_type newptr = reinterpret_cast<pointer_type>(::operator new(sizeof(T) * n));
499  return newptr;
500  }
501 
502  template<class S>
503  static pointer_type alloc(const S & obj, unsigned int n)
506  {
507  if (n == 0)
508  return NULL;
509  pointer_type newptr = reinterpret_cast<pointer_type>(::operator new(sizeof(T) * n));
510  for (unsigned i = 0; i < n; ++i)
511  ::new(static_cast<void *>(newptr + i)) T(obj);
512  return newptr;
513  }
514 
515  template<class S>
516  static pointer_type clone(S * ptr, unsigned int n)
519  {
520  if (n == 0)
521  return NULL;
522  pointer_type newptr = reinterpret_cast<pointer_type>(::operator new(sizeof(T) * n));
523  for (unsigned i = 0; i < n; ++i)
524  ::new(static_cast<void *>(newptr + i)) T(ptr[i]);
525  return newptr;
526  }
527 
528  template<class S>
529  static pointer_type clone(S * ptr, unsigned int n, unsigned int ncopy)
533  {
534  if (n == 0)
535  return NULL;
536  assert(ncopy <= n);
537  pointer_type newptr = reinterpret_cast<pointer_type>(::operator new(sizeof(T) * n));
538  for (unsigned i = 0; i < ncopy; ++i)
539  ::new(static_cast<void *>(newptr + i)) T(ptr[i]);
540  for (unsigned i = ncopy; i < n; ++i)
541  ::new(static_cast<void *>(newptr + i)) T();
542  return newptr;
543  }
544 
545  template<class S, class SS>
546  static pointer_type clone(S * ptr, unsigned int n, unsigned int ncopy, const SS & copyobj)
550  {
551  if (n == 0)
552  return NULL;
553  assert(ncopy <= n);
554  pointer_type newptr = reinterpret_cast<pointer_type>(::operator new(sizeof(T) * n));
555  for (unsigned i = 0; i < ncopy; ++i)
556  ::new(static_cast<void *>(newptr + i)) T(ptr[i]);
557  for (unsigned i = ncopy; i < n; ++i)
558  ::new(static_cast<void *>(newptr + i)) T(copyobj);
559  return newptr;
560  }
561 
562 #if __cplusplus >= 201103L
563  template<class S>
564  static pointer_type clone_move(S * ptr, unsigned int n)
567  {
568  if (n == 0)
569  return NULL;
570  pointer_type newptr = reinterpret_cast<pointer_type>(::operator new(sizeof(T) * n));
571  for (unsigned i = 0; i < n; ++i)
572  ::new(static_cast<void *>(newptr + i)) T(std::move(ptr[i]));
573  return newptr;
574  }
575 
576  template<class S>
577  static pointer_type clone_move(S * ptr, unsigned int n, unsigned int ncopy)
581  {
582  if (n == 0)
583  return NULL;
584  assert(ncopy <= n);
585  pointer_type newptr = reinterpret_cast<pointer_type>(::operator new(sizeof(T) * n));
586  for (unsigned i = 0; i < ncopy; ++i)
587  ::new(static_cast<void *>(newptr + i)) T(std::move(ptr[i]));
588  for (unsigned i = ncopy; i < n; ++i)
589  ::new(static_cast<void *>(newptr + i)) T();
590  return newptr;
591  }
592 
593  template<class S, class SS>
594  static pointer_type clone_move(S * ptr, unsigned int n, unsigned int ncopy, const SS & copyobj)
598  {
599  if (n == 0)
600  return NULL;
601  assert(ncopy <= n);
602  pointer_type newptr = reinterpret_cast<pointer_type>(::operator new(sizeof(T) * n));
603  for (unsigned i = 0; i < ncopy; ++i)
604  ::new(static_cast<void *>(newptr + i)) T(std::move(ptr[i]));
605  for (unsigned i = ncopy; i < n; ++i)
606  ::new(static_cast<void *>(newptr + i)) T(copyobj);
607  return newptr;
608  }
609 #endif
610 
611  static void free(pointer_type ptr, unsigned int n)
613  {
614  if (n == 0)
615  return;
616  for (unsigned i = 0; i < n; ++i)
617  (ptr + i)->~T();
618  ::operator delete(ptr);
619  }
620 
621  inline static void check(pointer_type ptr, unsigned int n)
624  {
625  }
626  };
627 
628  #endif
629  }
630 }
631 
632 #endif
static pointer_type clone(S *ptr, unsigned int n, unsigned int ncopy)
Creates an array of n elements of type T. The first ncopy elements are copy-constructed from the give...
Definition: matrix-mem.hpp:529
static void free(pointer_type ptr, unsigned int n)
Destroys an array of n elements of type T.
Definition: matrix-mem.hpp:611
static void construct(ref_type ref)
Constructs an object via default constructor.
Definition: matrix-mem.hpp:458
static pointer_type clone(S *ptr, unsigned int n, unsigned int ncopy, const SS &copyobj)
Creates an array of n elements of type T. The first ncopy elements are copy-constructed from the give...
Definition: matrix-mem.hpp:546
static void copy_construct(ref_type ref, const S &obj)
Constructs an object via copy constructor.
Definition: matrix-mem.hpp:465
Provides means to allocate, reallocate and release (linear) arrays of objects of type T...
Definition: matrix-mem.hpp:450
static pointer_type clone(S *ptr, unsigned int n)
Creates an array of n elements of type T. The entries are copy-constructed from the given array ptr (...
Definition: matrix-mem.hpp:516
static void check(pointer_type ptr, unsigned int n)
Verifies the integrity of an array of n elements of type T. Does nothing for the release memory manag...
Definition: matrix-mem.hpp:621
static pointer_type alloc(const S &obj, unsigned int n)
Creates an array of n elements of type T, all being copies of obj (of type S).
Definition: matrix-mem.hpp:503
static pointer_type alloc_dontconstruct(unsigned int n)
Creates an array of n elements of type T. The entries are not constructed.
Definition: matrix-mem.hpp:492
static pointer_type alloc(unsigned int n)
Creates an array of n elements of type T. The entries are created using the default constructor...
Definition: matrix-mem.hpp:480