Open JarekParal opened 5 years ago
You cannot have a compile-time check on function argument as you are not guaranteed to get a compile-time constant. You would have to make the constructor templated by the servo parameters and hence, prevent them from being computed in run-time.
Isn't a simple assert enough in this case? You can log the error using the ESPlog library (https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/system/log.html)
Is it possible to have some compile-time check of the
attach()
parameters, e.g. withconstexp
?https://github.com/RoboticsBrno/ESP32-Arduino-Servo-Library/blob/4b1f4a560bc0e25c51faf7ac7a7fc35773a4ba7c/src/Servo.cpp#L60
I am now thinking about modification like this:
But that is a hidden side effect and I would like rather make the check in the compile-time and show same compile message (if the parameters would be constexp). Is that possible @yaqwsx ?
Or is there some better way? Are exceptions available in the Arduino EPS32 framework or how the ESP-IDF throws the error message?