TNB Library
TnbNewPlacement.h
[詳解]
1#pragma once
13#pragma warning( disable : 4100 )
14
15
16
17#ifndef _TnbDOXYGEN //Document作成用シンボル
18
19/*
20 * PLACEMENT NEW
21 * @param P ポインタ
22 * @return Pと同じ値
23 */
24template<typename T>
25inline LPVOID __cdecl operator new(size_t, T* P)
26{
27 return (P);
28}
29
30/*
31 * PLACEMENT DELETE
32 * @param V ダミー
33 * @param P ダミー
34 */
35template<typename T>
36inline void __cdecl operator delete(LPVOID V, T* P)
37{
38 return;
39}
40
41#endif //Document作成用シンボル
42
43
44
45//TNB Library
46namespace TNB
47{
48
49
50
79template<typename TYP>
80inline void PlacementNew(TYP* P)
81{
82 #ifndef _DEBUG
83 new(P) TYP;
84 #else
85 VERIFY( (new(P) TYP) == P );
86 #endif
87}
88
89
90
118template<typename TYP>
119inline void PlacementNew(int iLen, TYP* P)
120{
121 for ( int i = 0; i < iLen; i++ )
122 {
123 #ifndef _DEBUG
124 new(P) TYP;
125 #else
126 VERIFY( (new(P) TYP) == P );
127 #endif
128 P++;
129 }
130}
131
132
133
144template<typename TYP>
145inline void PlacementDelete(TYP* P)
146{
147 P->~TYP();
148}
149
150
151
163template<typename TYP>
164inline void PlacementDelete(int iLen, TYP* P)
165{
166 for ( int i = 0; i < iLen; i++ )
167 {
168 P->~TYP();
169 P++;
170 }
171}
172
173
174
175};//TNB
176
177
178
179#ifndef _TnbUSINGNAMESPACE_DISABLE
180 using namespace TNB;
181#endif
void PlacementDelete(TYP *P)
PLACEMENT DELETE.
void PlacementNew(TYP *P)
PLACEMENT NEW.
TNB Library
Definition: TnbDoxyTitle.txt:2