Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
35995856
Commit
35995856
authored
Oct 17, 2016
by
Wenzel Jakob
Committed by
GitHub
Oct 17, 2016
Browse files
Merge pull request #450 from dean0x7d/explicit-bool
Make operator bool() explicit
parents
135fd149
c889ebd0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
include/pybind11/pytypes.h
include/pybind11/pytypes.h
+2
-2
No files found.
include/pybind11/pytypes.h
View file @
35995856
...
...
@@ -88,7 +88,7 @@ public:
const
handle
&
dec_ref
()
const
{
Py_XDECREF
(
m_ptr
);
return
*
this
;
}
template
<
typename
T
>
T
cast
()
const
;
operator
bool
()
const
{
return
m_ptr
!=
nullptr
;
}
explicit
operator
bool
()
const
{
return
m_ptr
!=
nullptr
;
}
bool
operator
==
(
const
handle
&
h
)
const
{
return
m_ptr
==
h
.
m_ptr
;
}
bool
operator
!=
(
const
handle
&
h
)
const
{
return
m_ptr
!=
h
.
m_ptr
;
}
bool
check
()
const
{
return
m_ptr
!=
nullptr
;
}
...
...
@@ -572,7 +572,7 @@ public:
class
bool_
:
public
object
{
public:
PYBIND11_OBJECT_DEFAULT
(
bool_
,
object
,
PyBool_Check
)
// Allow implicit conversion from `bool`:
// Allow implicit conversion from
and to
`bool`:
bool_
(
bool
value
)
:
object
(
value
?
Py_True
:
Py_False
,
true
)
{
}
operator
bool
()
const
{
return
m_ptr
&&
PyLong_AsLong
(
m_ptr
)
!=
0
;
}
};
...
...
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