suppress warnings in tests for deprecated functions
[folly.git] / folly / MapUtil.h
index b95da417ffe3f353dde541e6845b201ba16806da..7bdb60b734618f9300a456d5bc11078016f7145d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2012-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,15 +39,9 @@ template <
     typename std::enable_if<!is_invocable<Value>::value>::type* = nullptr>
 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);
-  if (pos != map.end()) {
-    return pos->second;
-  } else {
-    // if elision from function parameters was allowed, then we could make the
-    // third parameter a value parameter and just elide that into the return
-    // value, but sadly that is not allowed (yet)
-    return std::forward<Value>(dflt);
-  }
+  return (pos != map.end()) ? (pos->second) : M(std::forward<Value>(dflt));
 }
 
 /**