Skip to content

Commit d3746a9

Browse files
committed
Improve readability using data()
1 parent a2bbae2 commit d3746a9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/pybind11/detail/class.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ extern "C" inline int pybind11_getbuffer(PyObject *obj, Py_buffer *view, int fla
576576
view->format = const_cast<char *>(info->format.c_str());
577577
if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES) {
578578
view->ndim = (int) info->ndim;
579-
view->strides = &info->strides[0];
580-
view->shape = &info->shape[0];
579+
view->strides = (info->strides).data();
580+
view->shape = (info->shape).data();
581581
}
582582
Py_INCREF(view->obj);
583583
return 0;

tests/test_sequences_and_iterators.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ TEST_SUBMODULE(sequences_and_iterators, m) {
168168
explicit Sequence(const std::vector<float> &value) : m_size(value.size()) {
169169
print_created(this, "of size", m_size, "from std::vector");
170170
m_data = new float[m_size];
171-
memcpy(m_data, &value[0], sizeof(float) * m_size);
171+
memcpy(m_data, value.data(), sizeof(float) * m_size);
172172
}
173173
Sequence(const Sequence &s) : m_size(s.m_size) {
174174
print_copy_created(this);

0 commit comments

Comments
 (0)