For std::pair
, I am just curious to know why this works
std::pair<int, int> response = {1, 2}
while, this doesn't:
if (response == {1, 2}) do something;
Is it because the operator =
is overloaded for std::pair while ==
isn't?
This is just syntax: braced-init-list can be an operand only to []
and ()
(on the inside) and =
and any @=
(on the right). The initialization case is also allowed, where there is no operator at all.