I have a Line
that represents the relevant information of a line on the cartesian plane. The type that has, among other members, a bool
that indicates whether the slope is defined. I would like to be able to do the following:
if(my_line){
double new_slope = my_line.slope * 9;
}
where the instance my_line
itself is implicitly converted to a true/false value in a boolean context. I am thinking of the behavior I see with smart pointers, where if it is pointing to nullptr
or 0
, the instance is considered false as-is.
How would I go about emulating this behavior?