mirror of
https://github.com/pybind/pybind11.git
synced 2025-01-31 15:20:34 +00:00
Merge branch 'master' into sh_merge_master
This commit is contained in:
commit
ae02940be9
@ -16,6 +16,7 @@
|
|||||||
#include "attr.h"
|
#include "attr.h"
|
||||||
#include "gil.h"
|
#include "gil.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
#include "typing.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -2707,7 +2708,7 @@ template <return_value_policy Policy = return_value_policy::reference_internal,
|
|||||||
typename Sentinel,
|
typename Sentinel,
|
||||||
typename ValueType = typename detail::iterator_access<Iterator>::result_type,
|
typename ValueType = typename detail::iterator_access<Iterator>::result_type,
|
||||||
typename... Extra>
|
typename... Extra>
|
||||||
iterator make_iterator(Iterator first, Sentinel last, Extra &&...extra) {
|
typing::Iterator<ValueType> make_iterator(Iterator first, Sentinel last, Extra &&...extra) {
|
||||||
return detail::make_iterator_impl<detail::iterator_access<Iterator>,
|
return detail::make_iterator_impl<detail::iterator_access<Iterator>,
|
||||||
Policy,
|
Policy,
|
||||||
Iterator,
|
Iterator,
|
||||||
@ -2725,7 +2726,7 @@ template <return_value_policy Policy = return_value_policy::reference_internal,
|
|||||||
typename Sentinel,
|
typename Sentinel,
|
||||||
typename KeyType = typename detail::iterator_key_access<Iterator>::result_type,
|
typename KeyType = typename detail::iterator_key_access<Iterator>::result_type,
|
||||||
typename... Extra>
|
typename... Extra>
|
||||||
iterator make_key_iterator(Iterator first, Sentinel last, Extra &&...extra) {
|
typing::Iterator<KeyType> make_key_iterator(Iterator first, Sentinel last, Extra &&...extra) {
|
||||||
return detail::make_iterator_impl<detail::iterator_key_access<Iterator>,
|
return detail::make_iterator_impl<detail::iterator_key_access<Iterator>,
|
||||||
Policy,
|
Policy,
|
||||||
Iterator,
|
Iterator,
|
||||||
@ -2743,7 +2744,7 @@ template <return_value_policy Policy = return_value_policy::reference_internal,
|
|||||||
typename Sentinel,
|
typename Sentinel,
|
||||||
typename ValueType = typename detail::iterator_value_access<Iterator>::result_type,
|
typename ValueType = typename detail::iterator_value_access<Iterator>::result_type,
|
||||||
typename... Extra>
|
typename... Extra>
|
||||||
iterator make_value_iterator(Iterator first, Sentinel last, Extra &&...extra) {
|
typing::Iterator<ValueType> make_value_iterator(Iterator first, Sentinel last, Extra &&...extra) {
|
||||||
return detail::make_iterator_impl<detail::iterator_value_access<Iterator>,
|
return detail::make_iterator_impl<detail::iterator_value_access<Iterator>,
|
||||||
Policy,
|
Policy,
|
||||||
Iterator,
|
Iterator,
|
||||||
@ -2758,8 +2759,10 @@ iterator make_value_iterator(Iterator first, Sentinel last, Extra &&...extra) {
|
|||||||
/// `std::begin()`/`std::end()`
|
/// `std::begin()`/`std::end()`
|
||||||
template <return_value_policy Policy = return_value_policy::reference_internal,
|
template <return_value_policy Policy = return_value_policy::reference_internal,
|
||||||
typename Type,
|
typename Type,
|
||||||
|
typename ValueType = typename detail::iterator_access<
|
||||||
|
decltype(std::begin(std::declval<Type &>()))>::result_type,
|
||||||
typename... Extra>
|
typename... Extra>
|
||||||
iterator make_iterator(Type &value, Extra &&...extra) {
|
typing::Iterator<ValueType> make_iterator(Type &value, Extra &&...extra) {
|
||||||
return make_iterator<Policy>(
|
return make_iterator<Policy>(
|
||||||
std::begin(value), std::end(value), std::forward<Extra>(extra)...);
|
std::begin(value), std::end(value), std::forward<Extra>(extra)...);
|
||||||
}
|
}
|
||||||
@ -2768,8 +2771,10 @@ iterator make_iterator(Type &value, Extra &&...extra) {
|
|||||||
/// `std::begin()`/`std::end()`
|
/// `std::begin()`/`std::end()`
|
||||||
template <return_value_policy Policy = return_value_policy::reference_internal,
|
template <return_value_policy Policy = return_value_policy::reference_internal,
|
||||||
typename Type,
|
typename Type,
|
||||||
|
typename KeyType = typename detail::iterator_key_access<
|
||||||
|
decltype(std::begin(std::declval<Type &>()))>::result_type,
|
||||||
typename... Extra>
|
typename... Extra>
|
||||||
iterator make_key_iterator(Type &value, Extra &&...extra) {
|
typing::Iterator<KeyType> make_key_iterator(Type &value, Extra &&...extra) {
|
||||||
return make_key_iterator<Policy>(
|
return make_key_iterator<Policy>(
|
||||||
std::begin(value), std::end(value), std::forward<Extra>(extra)...);
|
std::begin(value), std::end(value), std::forward<Extra>(extra)...);
|
||||||
}
|
}
|
||||||
@ -2778,8 +2783,10 @@ iterator make_key_iterator(Type &value, Extra &&...extra) {
|
|||||||
/// `std::begin()`/`std::end()`
|
/// `std::begin()`/`std::end()`
|
||||||
template <return_value_policy Policy = return_value_policy::reference_internal,
|
template <return_value_policy Policy = return_value_policy::reference_internal,
|
||||||
typename Type,
|
typename Type,
|
||||||
|
typename ValueType = typename detail::iterator_value_access<
|
||||||
|
decltype(std::begin(std::declval<Type &>()))>::result_type,
|
||||||
typename... Extra>
|
typename... Extra>
|
||||||
iterator make_value_iterator(Type &value, Extra &&...extra) {
|
typing::Iterator<ValueType> make_value_iterator(Type &value, Extra &&...extra) {
|
||||||
return make_value_iterator<Policy>(
|
return make_value_iterator<Policy>(
|
||||||
std::begin(value), std::end(value), std::forward<Extra>(extra)...);
|
std::begin(value), std::end(value), std::forward<Extra>(extra)...);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@ numpy==1.21.5; platform_python_implementation=="PyPy" and sys_platform=="linux"
|
|||||||
numpy==1.19.3; platform_python_implementation!="PyPy" and python_version=="3.6"
|
numpy==1.19.3; platform_python_implementation!="PyPy" and python_version=="3.6"
|
||||||
numpy==1.21.5; platform_python_implementation!="PyPy" and python_version>="3.7" and python_version<"3.10"
|
numpy==1.21.5; platform_python_implementation!="PyPy" and python_version>="3.7" and python_version<"3.10"
|
||||||
numpy==1.22.2; platform_python_implementation!="PyPy" and python_version>="3.10" and python_version<"3.11"
|
numpy==1.22.2; platform_python_implementation!="PyPy" and python_version>="3.10" and python_version<"3.11"
|
||||||
pytest==7.0.0
|
pytest==7.0.0; platform_python_implementation!="PyPy" and python_version=="3.6"
|
||||||
|
pytest==7.2.0; platform_python_implementation!="PyPy" and python_version>="3.7"
|
||||||
pytest-timeout
|
pytest-timeout
|
||||||
scipy==1.5.4; platform_python_implementation!="PyPy" and python_version<"3.10"
|
scipy==1.5.4; platform_python_implementation!="PyPy" and python_version<"3.10"
|
||||||
scipy==1.10.0; platform_python_implementation!="PyPy" and python_version=="3.10"
|
scipy==1.10.0; platform_python_implementation!="PyPy" and python_version=="3.10"
|
||||||
|
@ -58,6 +58,15 @@ def test_generalized_iterators_simple():
|
|||||||
assert list(m.IntPairs([(1, 2), (3, 4), (0, 5)]).simple_values()) == [2, 4, 5]
|
assert list(m.IntPairs([(1, 2), (3, 4), (0, 5)]).simple_values()) == [2, 4, 5]
|
||||||
|
|
||||||
|
|
||||||
|
def test_iterator_doc_annotations():
|
||||||
|
assert m.IntPairs.nonref.__doc__.endswith("-> Iterator[tuple[int, int]]\n")
|
||||||
|
assert m.IntPairs.nonref_keys.__doc__.endswith("-> Iterator[int]\n")
|
||||||
|
assert m.IntPairs.nonref_values.__doc__.endswith("-> Iterator[int]\n")
|
||||||
|
assert m.IntPairs.simple_iterator.__doc__.endswith("-> Iterator[tuple[int, int]]\n")
|
||||||
|
assert m.IntPairs.simple_keys.__doc__.endswith("-> Iterator[int]\n")
|
||||||
|
assert m.IntPairs.simple_values.__doc__.endswith("-> Iterator[int]\n")
|
||||||
|
|
||||||
|
|
||||||
def test_iterator_referencing():
|
def test_iterator_referencing():
|
||||||
"""Test that iterators reference rather than copy their referents."""
|
"""Test that iterators reference rather than copy their referents."""
|
||||||
vec = m.VectorNonCopyableInt()
|
vec = m.VectorNonCopyableInt()
|
||||||
|
Loading…
Reference in New Issue
Block a user