In javascript I can write the following:
const bar = getBar();
const foo = bar || 0;
If getBar()
returns a null value, foo will fallback to 0.
In C++ I could do this:
auto bar = getBar();
int foo = bar? bar: 0;
But is there a more concise way of doing this in C++?