py::builtins::list::end

iterator end();                                         // 1

const_iterator end() const;                             // 2
  1. Returns an iterator to one past the last element.

  2. Returns a constant iterator one past the last element.

Tip

(2) is equivalent to py::builtins::list::cend.

digraph begin_end { node [ shape = Mrecord, height = 0, width = 0, fontname = "Courier New", fontsize = 10 ]; array [ label = < <TABLE BGCOLOR="lightgrey" BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="12"> <TR> <TD PORT="begin"></TD> <TD></TD> <TD></TD> <TD></TD> <TD></TD> <TD></TD> <TD></TD> <TD></TD> <TD></TD> <TD></TD> <TD></TD> <TD></TD> <TD></TD> <TD></TD> <TD></TD> <TD PORT="end" STYLE="dotted" SIDES="TRB"></TD> </TR> </TABLE> >, shape = plaintext ] "begin" -> array:begin "end" -> array:end past_the_last [ label="Past the last element", fontname = "Helvetica", shape = plain ] past_the_last -> array:end [arrowhead="vee"] rank3 [style=invisible]; array -> rank3 [color=none] { rank = same; rank3; past_the_last; } }

Return value

  1. An iterator to one past the last element.

  2. A constant iterator to one past the last element.

Complexity

Constant.

Example

#include <pypp/builtins/list.hpp>
#include <pypp/builtins/print.hpp>

int main()
{
    py::list<int> list = {0, 0, 1, 3};
    py::print(*(list.end() - 1));
}

Output:

3