Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
0228080a
Commit
0228080a
authored
Feb 03, 2021
by
Ralf W. Grosse-Kunstleve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding // DANGER ZONE reminders.
parent
1e4f0fdc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletions
+3
-1
include/pybind11/detail/init.h
+3
-1
No files found.
include/pybind11/detail/init.h
View file @
0228080a
...
...
@@ -105,11 +105,13 @@ void construct(value_and_holder &v_h, Cpp<Class> *ptr, bool need_alias) {
// the holder and destruction happens when we leave the C++ scope, and the holder
// class gets to handle the destruction however it likes.
v_h
.
value_ptr
()
=
ptr
;
v_h
.
set_instance_registered
(
true
);
// To prevent init_instance from registering it
v_h
.
set_instance_registered
(
true
);
// SHORTCUT To prevent init_instance from registering it
// DANGER ZONE BEGIN: exceptions will leave v_h in an invalid state.
v_h
.
type
->
init_instance
(
v_h
.
inst
,
nullptr
);
// Set up the holder
Holder
<
Class
>
temp_holder
(
std
::
move
(
v_h
.
holder
<
Holder
<
Class
>>
()));
// Steal the holder
v_h
.
type
->
dealloc
(
v_h
);
// Destroys the moved-out holder remains, resets value ptr to null
v_h
.
set_instance_registered
(
false
);
// DANGER ZONE END.
construct_alias_from_cpp
<
Class
>
(
is_alias_constructible
<
Class
>
{},
v_h
,
std
::
move
(
*
ptr
));
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment