• Docs >
  • Program Listing for File max_element.hpp
Shortcuts

Program Listing for File max_element.hpp

Return to documentation for file (include/ripple/algorithm/max_element.hpp)

#ifndef RIPPLE_ALGORITHM_MAX_ELEMENT_HPP
#define RIPPLE_ALGORITHM_MAX_ELEMENT_HPP

#include <ripple/utility/forward.hpp>
#include <ripple/utility/portability.hpp>
#include <algorithm>

namespace ripple {
namespace detail {

template <typename T>
ripple_all constexpr auto
max_element_impl(T&& element) noexcept -> T&& {
  return ripple_forward(element);
}

template <typename T, typename Next, typename... Ts>
ripple_all constexpr decltype(auto)
max_element_impl(T&& current_max, Next&& next, Ts&&... rest) noexcept {
  return max_element_impl(
    std::max(ripple_forward(current_max), ripple_forward(next)),
    ripple_forward(rest)...);
}

} // namespace detail

template <typename T, typename... Ts>
ripple_all constexpr decltype(auto)
max_element(T&& first, Ts&&... rest) noexcept {
  return detail::max_element_impl(
    ripple_forward(first), ripple_forward(rest)...);
}

} // namespace ripple

#endif // RIPPLE_ALGORITHM_MAX_ELEMENT_HPP

Docs

Access comprehensive developer documentation for Ripple

View Docs

Tutorials

Get tutorials to help with understand all features

View Tutorials

Examples

Find examples to help get started

View Examples