Commit c3d71b54 authored by Eric Niebler's avatar Eric Niebler Committed by Facebook GitHub Bot

avoid Most Vexing Parse by using static_cast

Summary:
There is a Most Vexing Parse problem in `folly/MapUtil.h`:

```
xplat/folly/MapUtil.h:44:75: error: expected expression
  return (pos != map.end()) ? (pos->second) : M(std::forward<Value>(dflt));
                                                                          ^
```

Fix the issue by replacing paren-init with `static_cast`.

Reviewed By: yfeldblum, ispeters, ot

Differential Revision: D26610359

fbshipit-source-id: 89842b9b68cebaaab43ea5f82abe7e500f98ff2c
parent 924307b4
......@@ -41,7 +41,8 @@ typename Map::mapped_type get_default(
const Map& map, const Key& key, Value&& dflt) {
using M = typename Map::mapped_type;
auto pos = map.find(key);
return (pos != map.end()) ? (pos->second) : M(std::forward<Value>(dflt));
return (pos != map.end()) ? pos->second
: static_cast<M>(static_cast<Value&&>(dflt));
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment