Skip to content

py::list iterator not assignable #996

@crisluengo

Description

@crisluengo

This does not compile on GCC 5.4:

py::list out(1);
auto it = out.begin();
*it = py::cast(0);         // fails to compile

These other statements are OK:

out[0] = py::cast(0);      // works OK
out.append(py::cast(0));   // works OK

The error message indicates that *it is const. I guess it's related to this:

using list_iterator = generic_iterator<iterator_policies::sequence_fast_readonly>;

To me this is a bug, either in the documentation or in the code. Is there a specific reason for these iterators to be read-only? Am I supposed to create lists by appending elements one by one?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions