mirror of
https://github.com/boostorg/python.git
synced 2026-01-20 16:52:15 +00:00
forward.hpp
pointer_holder.hpp
value_holder.hpp
test/long.[py/cpp]
pointee.hpp, - begin making borland work.
cv_category.hpp,
referent_storage.hpp
instance.hpp
self.hpp - removed flotsam
signature.hpp - use vector instead of list
destroy.hpp - removed needless complication
make_keyword_range_fn.hpp - support for simpler init using vectors
class_converters.hpp - workaround for pro7
inheritance.hpp - simplified; took out pro7 workarounds; factored out
inheritance_query.hpp to reduce recompilation
dependencies
make_ptr_instance.hpp - add missing typename
registry.cpp - add a little invariant checking for metrowerks
class.cpp - stopped relying on class_id typedef
test/data_members.cpp - added a few more tests to make sure things compile at least.
test/destroy_test.cpp - removed cheating has_trivial_destructor tests
test/enum.cpp - added some pro7 workarounds
test/virtual_functions.[py/cpp] - added _some_ tests for callbacks which return by reference.
[SVN r18489]
52 lines
868 B
C++
52 lines
868 B
C++
#include <boost/python/detail/destroy.hpp>
|
|
#include <cassert>
|
|
|
|
int count;
|
|
int marks[] = {
|
|
-1
|
|
, -1, -1
|
|
, -1, -1, -1, -1
|
|
, -1
|
|
};
|
|
int* kills = marks;
|
|
|
|
struct foo
|
|
{
|
|
foo() : n(count++) {}
|
|
~foo()
|
|
{
|
|
*kills++ = n;
|
|
}
|
|
int n;
|
|
};
|
|
|
|
void assert_destructions(int n)
|
|
{
|
|
for (int i = 0; i < n; ++i)
|
|
assert(marks[i] == i);
|
|
assert(marks[n] == -1);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
assert_destructions(0);
|
|
typedef int a[2];
|
|
|
|
foo* f1 = new foo;
|
|
boost::python::detail::destroy_referent<foo const volatile&>(f1);
|
|
assert_destructions(1);
|
|
|
|
foo* f2 = new foo[2];
|
|
typedef foo x[2];
|
|
|
|
boost::python::detail::destroy_referent<x const&>(f2);
|
|
assert_destructions(3);
|
|
|
|
typedef foo y[2][2];
|
|
x* f3 = new y;
|
|
boost::python::detail::destroy_referent<y&>(f3);
|
|
assert_destructions(7);
|
|
|
|
return 0;
|
|
}
|