// Copyright (c) 2023, QuantStack and Mamba Contributors // // Distributed under the terms of the BSD 3-Clause License. // // The full license is in the file LICENSE, distributed with this software. #ifndef MAMBA_UTIL_CONDITIONAL_HPP #define MAMBA_UTIL_CONDITIONAL_HPP #include namespace mamba::util { template [[nodiscard]] auto if_else(bool condition, Int true_val, Int false_val) noexcept -> Int; /******************** * Implementation * ********************/ template auto if_else(bool condition, Int true_val, Int false_val) noexcept -> Int { if constexpr (std::is_enum_v) { using int_t = std::underlying_type_t; return static_cast( if_else(condition, static_cast(true_val), static_cast(false_val)) ); } else { return condition ? true_val : false_val; } } } #endif