A collection of library modules to facilitate the creation of full control loop algorithms, including state representation, motion planning, kinematics, dynamics and control.
I'd like to be able to check the truthiness of a State object. There are many cases where we check if a state is empty or not before doing something, and I think it would be convenient to have a direct operator for it.
// old way
if (!state.is_empty()) {
foo();
}
// new way
if (state) {
foo();
}
This mainly came to mind as I was working with Parameter objects and validating them by their emptiness.
Note that I used the explicit keyword, which restricts this operator to singularly logical evaluations (the solution to the safe-bool idiom since C++11). In other words, implicit conversions like bool x = state1 and weird side-effects such as state1 == state2 will still not be affected because of this.
I'd like to be able to check the truthiness of a State object. There are many cases where we check if a state is empty or not before doing something, and I think it would be convenient to have a direct operator for it.
This mainly came to mind as I was working with Parameter objects and validating them by their emptiness.
Note that I used the
explicit
keyword, which restricts this operator to singularly logical evaluations (the solution to the safe-bool idiom since C++11). In other words, implicit conversions likebool x = state1
and weird side-effects such asstate1 == state2
will still not be affected because of this.