diff --git a/libuavcan/include/uavcan/util/templates.hpp b/libuavcan/include/uavcan/util/templates.hpp index b90c8c3817..aa61ca1cb3 100644 --- a/libuavcan/include/uavcan/util/templates.hpp +++ b/libuavcan/include/uavcan/util/templates.hpp @@ -175,6 +175,24 @@ To coerceOrFallback(const From& from) * @} */ +/** + * Selects smaller value + */ +template +struct EnumMin +{ + enum { Result = (A < B) ? A : B }; +}; + +/** + * Selects larger value + */ +template +struct EnumMax +{ + enum { Result = (A > B) ? A : B }; +}; + /** * Compile time square root for integers. * Useful for operations on square matrices.