src
allocate.h
Go to the documentation of this file.
1 #ifndef _RE2C_UTIL_ALLOCATE_
2 #define _RE2C_UTIL_ALLOCATE_
3 
4 #include <stddef.h> // size_t
5 
6 namespace re2c {
7 
8 // useful fof allocation of arrays of POD objects
9 // 'new []' invokes default constructor for each object
10 // this can be unacceptable for performance reasons
11 template <typename T> T * allocate (size_t n)
12 {
13  void * p = operator new (n * sizeof (T));
14  return static_cast<T *> (p);
15 }
16 
17 } // namespace re2c
18 
19 #endif // _RE2C_UTIL_ALLOCATE_
T * allocate(size_t n)
Definition: allocate.h:11
Definition: bitmap.cc:10