/* * libfud * Copyright 2025 Dominick Allen * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** \file This file breaks a dependency chain; min and max are intended to be part of fud_algorithm. * * Consumers are encouraged to include fud_algorithm.hpp instead. */ #ifndef FUD_ALGORITHM_NO_DEP_HPP #define FUD_ALGORITHM_NO_DEP_HPP #include #include namespace fud { // NOLINTBEGIN(bugprone-return-const-ref-from-parameter) template concept LessThanComparable = requires(T lhs, T rhs) { { lhs < rhs } -> std::convertible_to; }; template constexpr const T& min(const T& lhs, const T& rhs) { if (lhs < rhs) { return lhs; } return rhs; } template constexpr const T& max(const T& lhs, const T& rhs) { if (lhs < rhs) { return rhs; } return lhs; } template constexpr const T& max(const T& first, const T& second, Args&&... args) { return max(first, max(second, std::forward(args)...)); } template constexpr const T& min(const T& first, const T& second, Args&&... args) { return min(first, min(second, std::forward(args)...)); } // NOLINTEND(bugprone-return-const-ref-from-parameter) } // namespace fud #endif