py::builtins::list::list

list();                                                 // 1

template <class array_t>
explicit list(const array_t& array);                    // 2

list(const std::initializer_list<type>& array);         // 3

list(const list& other);                                // 4

list(list&& other);                                     // 5
  1. Constructs an empty list.

  2. Constructs a list from another iterable object.

  3. Constructs a list from a initializer list.

  4. Copy constructs a list.

  5. Move constructs a list.

Template parameters

array_t: The type of another iterable object.

Parameters

array: (2): another iterable object, (3): an initializer list.

other: Another py::builtins::list object.

Complexity

  1. Constant.

  2. Linear in the size of array.

  3. Same as (2).

  4. Linear in the size of other.

  5. Constant.

Example

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

int main()
{

    // Default constructor
    py::list<int> list;

    py::print(list); // No output...

    py::list<int> list2 = {0, 1, 2, 3, 4, 5, 6};

    py::print(list2);
}

Output:

{}
{0, 1, 2, 3, 4, 5, 6}