template<typename T>
if (std::is_same<T, FrontCameraSegment>::value) {
height = segment.height;
}
I have a template to process several sensors. One sends me a height property, the others do not. I need that value once in my code, the rest of the Visualize()
function is the same for every sensor.
So I wanted to check whether T is_same
with FrontCameraSegment and then I wanted to use the segment.height property once.
However, the compiler says that "height"
is not a member of all elements passed to T
which is logic.
Casts don't work because of the same reason.
Restructuring the sensors using inheritance is not possible (I am not allowed to do that part).
So my question: How can I tell the compiler that I checked that height
is a member?