diff options
author | 2015-12-08 08:22:45 -0800 | |
---|---|---|
committer | 2015-12-08 08:22:45 -0800 | |
commit | 0b81f1715d6af9f98f982d6511e48973aa5a836a (patch) | |
tree | 06924f7e4b7f14db21fe41ec03a6b95eec29efeb /runtime/base/variant_map.h | |
parent | 641c83a8645ef9fd99dca06ec30bae8449b959c7 (diff) | |
parent | 2433d4e17c3006b8262a0d9421e201fc84777208 (diff) |
Merge "Allow initializing runtime with parsed options." am: e0d25b156e
am: 2433d4e17c
* commit '2433d4e17c3006b8262a0d9421e201fc84777208':
Allow initializing runtime with parsed options.
Diffstat (limited to 'runtime/base/variant_map.h')
-rw-r--r-- | runtime/base/variant_map.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/runtime/base/variant_map.h b/runtime/base/variant_map.h index 82e5d2e21b..531cb37355 100644 --- a/runtime/base/variant_map.h +++ b/runtime/base/variant_map.h @@ -19,8 +19,11 @@ #include <memory.h> #include <map> +#include <type_traits> #include <utility> +#include "base/stl_util.h" + namespace art { // @@ -268,8 +271,9 @@ struct VariantMap { } // Set a value for a given key, overwriting the previous value if any. + // Note: Omit the `value` from TValue type deduction, deduce only from the `key` argument. template <typename TValue> - void Set(const TKey<TValue>& key, const TValue& value) { + void Set(const TKey<TValue>& key, const typename Identity<TValue>::type& value) { // Clone the value first, to protect against &value == GetValuePtr(key). auto* new_value = new TValue(value); @@ -279,8 +283,9 @@ struct VariantMap { // Set a value for a given key, only if there was no previous value before. // Returns true if the value was set, false if a previous value existed. + // Note: Omit the `value` from TValue type deduction, deduce only from the `key` argument. template <typename TValue> - bool SetIfMissing(const TKey<TValue>& key, const TValue& value) { + bool SetIfMissing(const TKey<TValue>& key, const typename Identity<TValue>::type& value) { TValue* ptr = Get(key); if (ptr == nullptr) { Set(key, value); |