#ifndef MBUOY_FIND_HPP #define MBUOY_FIND_HPP #include #include namespace mbuoy { template concept can_static_cast = requires(U u) { static_cast(u); }; template consteval std::optional find(T val) { return val; } template requires (!std::is_same_v && can_static_cast) consteval std::optional find(U val) { return val; } template requires (!std::is_same_v && !can_static_cast) consteval std::optional find(U val) { return {}; } template consteval std::optional find(T val, auto... vals) { return val; } template requires (!std::is_same_v && can_static_cast) consteval std::optional find(U val, auto... vals) { return val; } template requires (!std::is_same_v && !can_static_cast) consteval auto find(U val, auto... vals) { return find(vals...); } } // namespace mbuoy #endif // MBUOY_FIND_HPP