I’ve got a std::variant and I want to do a binary operation (say + for example) based on the types stored in the LHS and RHS of operation (which is a variant). Eg if the LHS and RHS were strings, we’d add them, and if they were ints we’d add them, but if we got a bool and an int we’d error.
Is there a really nice way to write this? I’m aware of std::visit but attempting to use it is leading to masses of over complex overloaded functions.
In an ideal world (this is my Python brain speaking) I’d like to write something like
If (LHS == int and RHS == int) then {do this}
So on