On 2013-09-13 16:17, Orvid King wrote:

Well, I usually do it as:

int[string] someCache;

int getValue(string key)
{
     if (auto val = key in someCache)
         return *val;
     return someCache[key] = -3;
}

That doesn't work with generic code. I mean, -3 can be a legal value. There are many types that doesn't have an invalid value, like pointers do.

--
/Jacob Carlborg

Reply via email to