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
68a99892
Commit
68a99892
authored
Oct 02, 2016
by
Wenzel Jakob
Committed by
GitHub
Oct 02, 2016
Browse files
Merge pull request #429 from jagerman/accessor-bool-operator
Re-add accessor bool operator
parents
103d78d3
7b8e3f9e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
include/pybind11/pytypes.h
include/pybind11/pytypes.h
+12
-0
No files found.
include/pybind11/pytypes.h
View file @
68a99892
...
@@ -206,6 +206,18 @@ public:
...
@@ -206,6 +206,18 @@ public:
void
operator
=
(
handle
value
)
&&
{
Policy
::
set
(
obj
,
key
,
value
);
}
void
operator
=
(
handle
value
)
&&
{
Policy
::
set
(
obj
,
key
,
value
);
}
void
operator
=
(
handle
value
)
&
{
get_cache
()
=
object
(
value
,
true
);
}
void
operator
=
(
handle
value
)
&
{
get_cache
()
=
object
(
value
,
true
);
}
template
<
typename
T
=
Policy
>
PYBIND11_DEPRECATED
(
"Use of obj.attr(...) as bool is deprecated in favor of pybind11::hasattr(obj, ...)"
)
operator
enable_if_t
<
std
::
is_same
<
T
,
accessor_policies
::
str_attr
>::
value
||
std
::
is_same
<
T
,
accessor_policies
::
obj_attr
>::
value
,
bool
>
()
const
{
return
hasattr
(
obj
,
key
);
}
template
<
typename
T
=
Policy
>
PYBIND11_DEPRECATED
(
"Use of obj[key] as bool is deprecated in favor of obj.contains(key)"
)
operator
enable_if_t
<
std
::
is_same
<
T
,
accessor_policies
::
generic_item
>::
value
,
bool
>
()
const
{
return
obj
.
contains
(
key
);
}
operator
object
()
const
{
return
get_cache
();
}
operator
object
()
const
{
return
get_cache
();
}
PyObject
*
ptr
()
const
{
return
get_cache
().
ptr
();
}
PyObject
*
ptr
()
const
{
return
get_cache
().
ptr
();
}
template
<
typename
T
>
T
cast
()
const
{
return
get_cache
().
template
cast
<
T
>();
}
template
<
typename
T
>
T
cast
()
const
{
return
get_cache
().
template
cast
<
T
>();
}
...
...
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