-
-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #699 from andreasfertig/pseudoDestructor
Added support for pseudo destructor.
- Loading branch information
Showing
6 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <new> | ||
|
||
namespace Test { | ||
template<typename T> | ||
struct Apple | ||
{ | ||
T x; | ||
}; | ||
|
||
template<typename T> | ||
void destroy(T* ptr) { | ||
ptr->T::~T(); | ||
} | ||
} | ||
|
||
namespace West | ||
{ | ||
int y; | ||
} | ||
|
||
int main() | ||
{ | ||
char buffer[sizeof(Test::Apple<int>)]; | ||
|
||
auto f = new (&buffer) Test::Apple<int>; | ||
|
||
f->Test::Apple<int>::~Apple<int>(); | ||
f->~Apple(); | ||
|
||
Test::destroy(f); | ||
|
||
int x; | ||
Test::destroy(&x); | ||
|
||
Test::destroy(&West::y); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include <new> | ||
|
||
namespace Test | ||
{ | ||
template<typename T> | ||
struct Apple | ||
{ | ||
T x; | ||
}; | ||
|
||
/* First instantiated from: PlacemenNew2Test.cpp:23 */ | ||
#ifdef INSIGHTS_USE_TEMPLATE | ||
template<> | ||
struct Apple<int> | ||
{ | ||
int x; | ||
// inline Apple() noexcept = default; | ||
}; | ||
|
||
#endif | ||
template<typename T> | ||
void destroy(T * ptr) | ||
{ | ||
ptr->~T(); | ||
} | ||
|
||
/* First instantiated from: PlacemenNew2Test.cpp:30 */ | ||
#ifdef INSIGHTS_USE_TEMPLATE | ||
template<> | ||
void destroy<Apple<int> >(Apple<int> * ptr) | ||
{ | ||
ptr->~Apple(); | ||
} | ||
#endif | ||
|
||
|
||
/* First instantiated from: PlacemenNew2Test.cpp:33 */ | ||
#ifdef INSIGHTS_USE_TEMPLATE | ||
template<> | ||
void destroy<int>(int * ptr) | ||
{ | ||
ptr->~int(); | ||
} | ||
#endif | ||
|
||
|
||
} | ||
|
||
namespace West | ||
{ | ||
int y; | ||
|
||
} | ||
|
||
int main() | ||
{ | ||
char buffer[4]; | ||
Test::Apple<int> * f = new (reinterpret_cast<void *>(&buffer))Test::Apple<int>(); | ||
f->~Apple(); | ||
f->~Apple(); | ||
Test::destroy(f); | ||
int x; | ||
Test::destroy(&x); | ||
Test::destroy(&West::y); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <new> | ||
|
||
template<typename T> | ||
struct Apple | ||
{ | ||
T x; | ||
}; | ||
|
||
|
||
int main() | ||
{ | ||
char buffer[sizeof(Apple<int>)]; | ||
|
||
auto* f = new (&buffer) Apple<int>; | ||
|
||
auto& r = *f; | ||
|
||
r.~Apple<int>(); | ||
|
||
f->~Apple<int>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <new> | ||
|
||
template<typename T> | ||
struct Apple | ||
{ | ||
T x; | ||
}; | ||
|
||
/* First instantiated from: PlacemenNewTest.cpp:12 */ | ||
#ifdef INSIGHTS_USE_TEMPLATE | ||
template<> | ||
struct Apple<int> | ||
{ | ||
int x; | ||
// inline Apple() noexcept = default; | ||
}; | ||
|
||
#endif | ||
|
||
int main() | ||
{ | ||
char buffer[4]; | ||
Apple<int> * f = new (reinterpret_cast<void *>(&buffer))Apple<int>(); | ||
Apple<int> & r = *f; | ||
r.~Apple(); | ||
f->~Apple(); | ||
return 0; | ||
} |