py::builtins::max¶
Defined in <pypp/builtins/max.hpp>
template <class it_type>
constexpr auto max(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& max(const type& a, const arguments&... args); // 2
Returns the maximum value in an iterable.
Returns the maximum 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¶
The maximum value in the iterable.
The maximum value in provided arguments.
Complexity¶
Linear in the size of
iterable.Linear in the count of total arguments.
Example¶
#include <pypp/builtins/max.hpp>
#include <pypp/builtins/print.hpp>
int main()
{
py::print(py::max(2, 3, 1, 4, 9));
}
Output:
9