py::builtins::min

Defined in <pypp/builtins/min.hpp>

template <class it_type>
constexpr auto min(const it_type& iterable) -> decltype(*iterable.begin()); // 1

template <
    class type,
    class... arguments,
    class = std::enable_if_t<
        std::conjunction<
            std::is_same<type, arguments>...
        >::value
    >
>
const type& min(const type& a, const arguments&... args);                   // 2
  1. Returns the minimum value in an iterable.

  2. Returns the minimum value in provided arguments.

Template parameters

it_type: Type of iterable.

type: Type of arguments to compare.

Requirements of it_type

it_type must be comparable.

Parameters

iterable: An iterable object.

a: A comparable object.

args: Variable number comparable objects.

Return value

  1. The minimum value in the iterable.

  2. The minimum value in provided arguments.

Complexity

  1. Linear in the size of iterable.

  2. Linear in the count of total arguments.

Example

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

int main()
{
    py::print(py::min(2, 3, 1, 4, 9));
}

Output:

1