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
146397ec
Commit
146397ec
authored
Sep 06, 2016
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow iterators with different RV policies (fixes #388)
parent
fe34241e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
include/pybind11/pybind11.h
+6
-5
No files found.
include/pybind11/pybind11.h
View file @
146397ec
...
@@ -1123,7 +1123,7 @@ PYBIND11_NOINLINE inline void keep_alive_impl(int Nurse, int Patient, handle arg
...
@@ -1123,7 +1123,7 @@ PYBIND11_NOINLINE inline void keep_alive_impl(int Nurse, int Patient, handle arg
keep_alive_impl
(
nurse
,
patient
);
keep_alive_impl
(
nurse
,
patient
);
}
}
template
<
typename
Iterator
,
typename
Sentinel
,
bool
KeyIterator
=
false
>
template
<
typename
Iterator
,
typename
Sentinel
,
bool
KeyIterator
,
typename
...
Extra
>
struct
iterator_state
{
struct
iterator_state
{
Iterator
it
;
Iterator
it
;
Sentinel
end
;
Sentinel
end
;
...
@@ -1139,10 +1139,10 @@ template <typename Iterator,
...
@@ -1139,10 +1139,10 @@ template <typename Iterator,
typename
ValueType
=
decltype
(
*
std
::
declval
<
Iterator
>
()),
typename
ValueType
=
decltype
(
*
std
::
declval
<
Iterator
>
()),
typename
...
Extra
>
typename
...
Extra
>
iterator
make_iterator
(
Iterator
first
,
Sentinel
last
,
Extra
&&
...
extra
)
{
iterator
make_iterator
(
Iterator
first
,
Sentinel
last
,
Extra
&&
...
extra
)
{
typedef
detail
::
iterator_state
<
Iterator
,
Sentinel
>
state
;
typedef
detail
::
iterator_state
<
Iterator
,
Sentinel
,
false
,
Extra
...
>
state
;
if
(
!
detail
::
get_type_info
(
typeid
(
state
)))
{
if
(
!
detail
::
get_type_info
(
typeid
(
state
)))
{
class_
<
state
>
(
handle
(),
""
)
class_
<
state
>
(
handle
(),
"
iterator
"
)
.
def
(
"__iter__"
,
[](
state
&
s
)
->
state
&
{
return
s
;
})
.
def
(
"__iter__"
,
[](
state
&
s
)
->
state
&
{
return
s
;
})
.
def
(
"__next__"
,
[](
state
&
s
)
->
ValueType
{
.
def
(
"__next__"
,
[](
state
&
s
)
->
ValueType
{
if
(
!
s
.
first
)
if
(
!
s
.
first
)
...
@@ -1157,15 +1157,16 @@ iterator make_iterator(Iterator first, Sentinel last, Extra &&... extra) {
...
@@ -1157,15 +1157,16 @@ iterator make_iterator(Iterator first, Sentinel last, Extra &&... extra) {
return
(
iterator
)
cast
(
state
{
first
,
last
,
true
});
return
(
iterator
)
cast
(
state
{
first
,
last
,
true
});
}
}
template
<
typename
Iterator
,
template
<
typename
Iterator
,
typename
Sentinel
,
typename
Sentinel
,
typename
KeyType
=
decltype
((
*
std
::
declval
<
Iterator
>
()).
first
),
typename
KeyType
=
decltype
((
*
std
::
declval
<
Iterator
>
()).
first
),
typename
...
Extra
>
typename
...
Extra
>
iterator
make_key_iterator
(
Iterator
first
,
Sentinel
last
,
Extra
&&
...
extra
)
{
iterator
make_key_iterator
(
Iterator
first
,
Sentinel
last
,
Extra
&&
...
extra
)
{
typedef
detail
::
iterator_state
<
Iterator
,
Sentinel
,
true
>
state
;
typedef
detail
::
iterator_state
<
Iterator
,
Sentinel
,
true
,
Extra
...
>
state
;
if
(
!
detail
::
get_type_info
(
typeid
(
state
)))
{
if
(
!
detail
::
get_type_info
(
typeid
(
state
)))
{
class_
<
state
>
(
handle
(),
""
)
class_
<
state
>
(
handle
(),
"
iterator
"
)
.
def
(
"__iter__"
,
[](
state
&
s
)
->
state
&
{
return
s
;
})
.
def
(
"__iter__"
,
[](
state
&
s
)
->
state
&
{
return
s
;
})
.
def
(
"__next__"
,
[](
state
&
s
)
->
KeyType
{
.
def
(
"__next__"
,
[](
state
&
s
)
->
KeyType
{
if
(
!
s
.
first
)
if
(
!
s
.
first
)
...
...
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