py::builtins::range::range

constexpr range(const type& stop);                                      // 1

constexpr range(type&& stop);                                           // 2

constexpr range(const type& start, const type& stop, long step = 1);    // 3

constexpr range(type&& start, type&& stop, long step = 1);              // 4
  1. Constructs an range with given stop.

  2. Same as (1).

  3. Constructs a range from given start, stop and step.

  4. Same as (3).

Parameters

start: The start of range. See py::builtins::range::stop.

stop: The stop of range (exclusive). See py::builtins::range::stop.

step: The step of range. See py::builtins::range::stop.

Complexity

Constant.

Example

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

int main()
{
    py::range<int> range(7);
    py::print(py::list<int>(range));
}

Output:

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