OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / ministl / defalloc.h
1 /*
2  *
3  * Copyright (c) 1994
4  * Hewlett-Packard Company
5  *
6  * Permission to use, copy, modify, distribute and sell this software
7  * and its documentation for any purpose is hereby granted without fee,
8  * provided that the above copyright notice appear in all copies and
9  * that both that copyright notice and this permission notice appear
10  * in supporting documentation.  Hewlett-Packard Company makes no
11  * representations about the suitability of this software for any
12  * purpose.  It is provided "as is" without express or implied warranty.
13  *
14  */
15
16 #ifndef DEFALLOC_H
17 #define DEFALLOC_H
18
19
20 template <class T>
21 inline void destroy(T* pointer)
22 {
23     pointer->~T();
24 }
25
26 static inline void destroy(char*) {}
27 static inline void destroy(unsigned char*) {}
28 static inline void destroy(short*) {}
29 static inline void destroy(unsigned short*) {}
30 static inline void destroy(int*) {}
31 static inline void destroy(unsigned int*) {}
32 static inline void destroy(long*) {}
33 static inline void destroy(unsigned long*) {}
34 static inline void destroy(float*) {}
35 static inline void destroy(double*) {}
36 static inline void destroy(char**) {}
37 static inline void destroy(unsigned char**) {}
38 static inline void destroy(short**) {}
39 static inline void destroy(unsigned short**) {}
40 static inline void destroy(int**) {}
41 static inline void destroy(unsigned int**) {}
42 static inline void destroy(long**) {}
43 static inline void destroy(unsigned long**) {}
44 static inline void destroy(float**) {}
45 static inline void destroy(double**) {}
46
47
48 template <class T>
49 inline void destroy(T* beg, T* end)
50 {
51     for ( ; beg != end; ++beg)
52         beg->~T();
53 }
54
55 static inline void destroy(char*, char*) {}
56 static inline void destroy(unsigned char*, unsigned char*) {}
57 static inline void destroy(short*, short*) {}
58 static inline void destroy(unsigned short*, unsigned short*) {}
59 static inline void destroy(int*, int*) {}
60 static inline void destroy(unsigned int*, unsigned int*) {}
61 static inline void destroy(long*, long*) {}
62 static inline void destroy(unsigned long*, unsigned long*) {}
63 static inline void destroy(float*, float*) {}
64 static inline void destroy(double*, double*) {}
65 static inline void destroy(char**, char**) {}
66 static inline void destroy(unsigned char**, unsigned char**) {}
67 static inline void destroy(short**, short**) {}
68 static inline void destroy(unsigned short**, unsigned short**) {}
69 static inline void destroy(int**, int**) {}
70 static inline void destroy(unsigned int**, unsigned int**) {}
71 static inline void destroy(long**, long**) {}
72 static inline void destroy(unsigned long**, unsigned long**) {}
73 static inline void destroy(float**, float**) {}
74 static inline void destroy(double**, double**) {}
75
76 #if defined (__GNUG__)
77 static inline void *operator new(size_t, void *place) { return place; }
78 static inline void *operator new[](size_t, void *place) { return place; }
79 #else
80
81 #include <new.h>
82
83 #endif
84
85 #endif