mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-11 08:03:55 +00:00
chore: Make stl_bind take slice as const_ref (#3852)
* Make stl_bind take slice as const_ref * Change eval order if * Silence MSVC warning
This commit is contained in:
parent
ab59f45d2e
commit
1b27b744c1
@ -1817,7 +1817,8 @@ private:
|
|||||||
if (holder_ptr) {
|
if (holder_ptr) {
|
||||||
init_holder_from_existing(v_h, holder_ptr, std::is_copy_constructible<holder_type>());
|
init_holder_from_existing(v_h, holder_ptr, std::is_copy_constructible<holder_type>());
|
||||||
v_h.set_holder_constructed();
|
v_h.set_holder_constructed();
|
||||||
} else if (inst->owned || detail::always_construct_holder<holder_type>::value) {
|
} else if (PYBIND11_SILENCE_MSVC_C4127(detail::always_construct_holder<holder_type>::value)
|
||||||
|
|| inst->owned) {
|
||||||
new (std::addressof(v_h.holder<holder_type>())) holder_type(v_h.value_ptr<type>());
|
new (std::addressof(v_h.holder<holder_type>())) holder_type(v_h.value_ptr<type>());
|
||||||
v_h.set_holder_constructed();
|
v_h.set_holder_constructed();
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ void vector_modifiers(
|
|||||||
/// Slicing protocol
|
/// Slicing protocol
|
||||||
cl.def(
|
cl.def(
|
||||||
"__getitem__",
|
"__getitem__",
|
||||||
[](const Vector &v, slice slice) -> Vector * {
|
[](const Vector &v, const slice &slice) -> Vector * {
|
||||||
size_t start = 0, stop = 0, step = 0, slicelength = 0;
|
size_t start = 0, stop = 0, step = 0, slicelength = 0;
|
||||||
|
|
||||||
if (!slice.compute(v.size(), &start, &stop, &step, &slicelength)) {
|
if (!slice.compute(v.size(), &start, &stop, &step, &slicelength)) {
|
||||||
@ -253,7 +253,7 @@ void vector_modifiers(
|
|||||||
|
|
||||||
cl.def(
|
cl.def(
|
||||||
"__setitem__",
|
"__setitem__",
|
||||||
[](Vector &v, slice slice, const Vector &value) {
|
[](Vector &v, const slice &slice, const Vector &value) {
|
||||||
size_t start = 0, stop = 0, step = 0, slicelength = 0;
|
size_t start = 0, stop = 0, step = 0, slicelength = 0;
|
||||||
if (!slice.compute(v.size(), &start, &stop, &step, &slicelength)) {
|
if (!slice.compute(v.size(), &start, &stop, &step, &slicelength)) {
|
||||||
throw error_already_set();
|
throw error_already_set();
|
||||||
@ -281,7 +281,7 @@ void vector_modifiers(
|
|||||||
|
|
||||||
cl.def(
|
cl.def(
|
||||||
"__delitem__",
|
"__delitem__",
|
||||||
[](Vector &v, slice slice) {
|
[](Vector &v, const slice &slice) {
|
||||||
size_t start = 0, stop = 0, step = 0, slicelength = 0;
|
size_t start = 0, stop = 0, step = 0, slicelength = 0;
|
||||||
|
|
||||||
if (!slice.compute(v.size(), &start, &stop, &step, &slicelength)) {
|
if (!slice.compute(v.size(), &start, &stop, &step, &slicelength)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user