blob: a7b8d3b17f3b081612f3b6d5f9132cb52d7e0058 [file] [log] [blame]
#pragma once
#include <exception>
namespace pid_control
{
struct VariantToDoubleVisitor
{
template <typename T>
std::enable_if_t<std::is_arithmetic<T>::value, double>
operator()(const T& t) const
{
return static_cast<double>(t);
}
template <typename T>
std::enable_if_t<!std::is_arithmetic<T>::value, double>
operator()(const T& t) const
{
throw std::invalid_argument("Cannot translate type to double");
}
};
} // namespace pid_control