Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
407c2920
Commit
407c2920
authored
Jun 21, 2016
by
Wenzel Jakob
Committed by
GitHub
Jun 21, 2016
Browse files
Merge pull request #247 from aldanor/iterators
Use prefix increment in make_iterator
parents
9edfd20d
daed1abc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
include/pybind11/common.h
include/pybind11/common.h
+1
-1
include/pybind11/pybind11.h
include/pybind11/pybind11.h
+10
-3
No files found.
include/pybind11/common.h
View file @
407c2920
...
@@ -116,7 +116,7 @@
...
@@ -116,7 +116,7 @@
extern
"C"
{
extern
"C"
{
struct
_Py_atomic_address
{
void
*
value
;
};
struct
_Py_atomic_address
{
void
*
value
;
};
PyAPI_DATA
(
_Py_atomic_address
)
_PyThreadState_Current
;
PyAPI_DATA
(
_Py_atomic_address
)
_PyThreadState_Current
;
}
;
}
#endif
#endif
#define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1) // special failure return code
#define PYBIND11_TRY_NEXT_OVERLOAD ((PyObject *) 1) // special failure return code
...
...
include/pybind11/pybind11.h
View file @
407c2920
...
@@ -1028,7 +1028,10 @@ PYBIND11_NOINLINE inline void keep_alive_impl(int Nurse, int Patient, handle arg
...
@@ -1028,7 +1028,10 @@ PYBIND11_NOINLINE inline void keep_alive_impl(int Nurse, int Patient, handle arg
(
void
)
wr
.
release
();
(
void
)
wr
.
release
();
}
}
template
<
typename
Iterator
>
struct
iterator_state
{
Iterator
it
,
end
;
};
template
<
typename
Iterator
>
struct
iterator_state
{
Iterator
it
,
end
;
bool
first
;
};
NAMESPACE_END
(
detail
)
NAMESPACE_END
(
detail
)
...
@@ -1044,13 +1047,17 @@ iterator make_iterator(Iterator first, Iterator last, Extra &&... extra) {
...
@@ -1044,13 +1047,17 @@ iterator make_iterator(Iterator first, Iterator last, Extra &&... extra) {
class_
<
state
>
(
handle
(),
""
)
class_
<
state
>
(
handle
(),
""
)
.
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
)
++
s
.
it
;
else
s
.
first
=
false
;
if
(
s
.
it
==
s
.
end
)
if
(
s
.
it
==
s
.
end
)
throw
stop_iteration
();
throw
stop_iteration
();
return
*
s
.
it
++
;
return
*
s
.
it
;
},
return_value_policy
::
reference_internal
,
std
::
forward
<
Extra
>
(
extra
)...);
},
return_value_policy
::
reference_internal
,
std
::
forward
<
Extra
>
(
extra
)...);
}
}
return
(
iterator
)
cast
(
state
{
first
,
last
});
return
(
iterator
)
cast
(
state
{
first
,
last
,
true
});
}
}
template
<
typename
Type
,
typename
...
Extra
>
iterator
make_iterator
(
Type
&
value
,
Extra
&&
...
extra
)
{
template
<
typename
Type
,
typename
...
Extra
>
iterator
make_iterator
(
Type
&
value
,
Extra
&&
...
extra
)
{
...
...
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