This ternary, when used as-is, spits out a pointer:
std::stringstream ss;
ss << pair.second ? pair.second->toString() : "null";
std::cout << ss.str() << '\n';
This is a sample output:
{
"glossary": 000002B96B321F48
}
But when I surround the ternary operator in parenthesis, it works properly and gives me either the contents of toString() or "null".
ss << (pair.second ? pair.second->toString() : "null");
Also, expanding it to a proper if/else fixes it as well:
if (pair.second)
{
ss << pair.second->toString();
}
else
{
ss << "null";
}
What's going on?