On 4/17/18 4:49 PM, Steven Schveighoffer wrote:
On 4/17/18 12:18 PM, Nick Treleaven wrote:
Thanks for making this pull, I've thought about solving this before. I
think the function needs to provide a way to tell if the value was
already present.
Not as straightforward, but it can be done:
bool inserted = false;
auto p = aa.getOrAdd("key", {inserted = true; return new Person; });
Let me say I was surprised that this doesn't actually work. An in-line
lambda will NOT work as a lazy parameter, even though that's EXACTLY
what a lazy parameter is implemented as! And variadic lazy parameters
are explicitly typed this way.
Has that ever worked? I could have sworn it did...
-Steve