blob: a7b8d3b17f3b081612f3b6d5f9132cb52d7e0058 [file] [log] [blame]
Patrick Ventureaadb30d2020-08-10 09:17:11 -07001#pragma once
2
3#include <exception>
4
5namespace pid_control
6{
7
8struct VariantToDoubleVisitor
9{
10 template <typename T>
11 std::enable_if_t<std::is_arithmetic<T>::value, double>
12 operator()(const T& t) const
13 {
14 return static_cast<double>(t);
15 }
16
17 template <typename T>
18 std::enable_if_t<!std::is_arithmetic<T>::value, double>
19 operator()(const T& t) const
20 {
21 throw std::invalid_argument("Cannot translate type to double");
22 }
23};
24
25} // namespace pid_control