![]() |
Home | Libraries | People | FAQ | More |
This is how you solve it with boost::optional
:
#include <boost/optional.hpp> boost::optional<int> getConfigParam(std::string name); // return either an int or a `not-an-int` int main() { if (boost::optional<int> oi = getConfigParam("MaxValue")) // did I get a real int? runWithMax(*oi); // use my int else runWithNoMax(); }