Closed
Description
Required prerequisites
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
- Consider asking first in the Gitter chat room or in a Discussion.
Problem description
previously compiling code fails with gcc 12.1.0:
/usr/include/pybind11/pybind11.h:2347:29: error: lvalue required as increment operand
relevant code:
pybind11/include/pybind11/pybind11.h
Lines 2336 to 2360 in 1e3400b
Reproducible example code
#include <pybind11/pybind11.h>
#include <vector>
#include <pybind11/stl.h>
namespace py = pybind11;
using namespace py::literals;
class Vec {
public:
Vec(double x, double y, double z) {
values[0] = x;
values[1] = y;
values[2] = z;
};
double values[3];
};
PYBIND11_MODULE(mymodule, m) {
py::class_<Vec>(m, "Vec")
.def(py::init<double, double, double>())
.def("__iter__", [](const Vec& v){
return py::make_iterator(v.values, v.values+3);
}, py::keep_alive<0, 1>());
}