Use std::addressof to obtain holder address instead of operator&
diff --git a/tests/test_smart_ptr.py b/tests/test_smart_ptr.py
index 4dfe003..60f48b3 100644
--- a/tests/test_smart_ptr.py
+++ b/tests/test_smart_ptr.py
@@ -203,6 +203,50 @@
assert stats.alive() == 0
+def test_holder_with_addressof_operator():
+ # this test must not throw exception from c++
+ a = m.TypeForHolderWithAddressOf.make()
+ a.print_object_1()
+ a.print_object_2()
+ a.print_object_3()
+ a.print_object_4()
+
+ stats = ConstructorStats.get(m.TypeForHolderWithAddressOf)
+ assert stats.alive() == 1
+
+ np = m.TypeForHolderWithAddressOf.make()
+ assert stats.alive() == 2
+ del a
+ assert stats.alive() == 1
+ del np
+ assert stats.alive() == 0
+
+ b = m.TypeForHolderWithAddressOf.make()
+ c = b
+ assert b.get() is c.get()
+ assert stats.alive() == 1
+
+ del b
+ assert stats.alive() == 1
+
+ del c
+ assert stats.alive() == 0
+
+
+def test_move_only_holder_with_addressof_operator():
+ a = m.TypeForMoveOnlyHolderWithAddressOf.make()
+ a.print_object()
+
+ stats = ConstructorStats.get(m.TypeForMoveOnlyHolderWithAddressOf)
+ assert stats.alive() == 1
+
+ a.value = 42
+ assert a.value == 42
+
+ del a
+ assert stats.alive() == 0
+
+
def test_smart_ptr_from_default():
instance = m.HeldByDefaultHolder()
with pytest.raises(RuntimeError) as excinfo: