get_ptr(mapOfMaps, key, key...)
authorTom Jackson <tjackson@fb.com>
Mon, 13 Mar 2017 18:09:00 +0000 (11:09 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Mon, 13 Mar 2017 18:26:24 +0000 (11:26 -0700)
commita2353bc0411329fa89e837bd06c869b5367381ba
tree92f87cbf63f33bb84db2e1d44868893b15e5d97d
parent1352041862936c4fde82b038e455dce8a5f84195
get_ptr(mapOfMaps, key, key...)

Summary:
Since this is a not-uncommon pattern now:

```lang=cpp
if (auto found1 = get_ptr(m, k1)) {
  if (auto found2 = get_ptr(*found, k2)) {
    return use(*found2);
  }
}
```

This diff enables:

```lang=cpp
if (auto found = get_ptr(m, k1, k2)) {
  return use(*found);
}

```

Note that it works for const and non-const maps, returning a correspondingly mutable pointer.

Reviewed By: luciang, yfeldblum

Differential Revision: D3812701

fbshipit-source-id: 77ace9f5dca6cdc4cae7e6dfb9e5fc1075b5b571
folly/MapUtil.h
folly/test/MapUtilTest.cpp