py::builtins::list¶
Defined in <pypp/builtins/list.hpp>
template <
class type,
class allocator = std::allocator<type>
>
class list;
Container for holding and randomly accessing elements of a single type.
py::builtins::list allows to hold elements of a single type and
access them randomly in constant time.
This container stores element contiguously, so elements can be
accessed with offsets on pointers to other elements (not applicable
when element type is bool, see below).
Note
py::builtins::list uses std::vector to hold elements, so
when using this container to hold element of type bool,
every element usually uses a bit instead of a byte
(depends on the C++ standard library implementation).
Non-member helpers¶
Example¶
#include <pypp/builtins/list.hpp>
#include <pypp/builtins/print.hpp>
int main()
{
py::list<int> list = {0, 1, 2, 3, 4, 5, 6};
py::print(list);
list.append(7);
py::print(list);
}
Output:
{0, 1, 2, 3, 4, 5, 6}
{0, 1, 2, 3, 4, 5, 6, 7}