std::optional<bool> role;
if (role.value())
{ std::cerr ("User is admin");}
else if (!role.value())
{ std::cerr ("User is not admin");}
else if (!role.has_value())
{ std::cerr ("User is not logged in");}
Here has_value() should have been checked first, but the JS seems kinda fine.
Which is it?
a === b returns true if a and b have the same type and are considered equal, and false otherwise. If a is null and b is a boolean, it will simply return false.
Same as ?
Here
has_value()
should have been checked first, but the JS seems kinda fine.Which is it?
a === b
returns true ifa
andb
have the same type and are considered equal, and false otherwise. Ifa
isnull
andb
is a boolean, it will simply return false.