std::forward<V>(v))).first->second;
}
+template<class K> inline dynamic& dynamic::setDefault(K&& k, dynamic&& v) {
+ auto& obj = get<ObjectImpl>();
+ return obj.insert(std::make_pair(std::forward<K>(k),
+ std::move(v))).first->second;
+}
+
+template<class K> inline dynamic& dynamic::setDefault(K&& k, const dynamic& v) {
+ auto& obj = get<ObjectImpl>();
+ return obj.insert(std::make_pair(std::forward<K>(k), v)).first->second;
+}
+
inline dynamic* dynamic::get_ptr(dynamic const& idx) & {
return const_cast<dynamic*>(const_cast<dynamic const*>(this)->get_ptr(idx));
}
dynamic getDefault(const dynamic& k, dynamic&& v) const&;
dynamic getDefault(const dynamic& k, const dynamic& v = dynamic::object) &&;
dynamic getDefault(const dynamic& k, dynamic&& v) &&;
- template<class K, class V = dynamic>
- dynamic& setDefault(K&& k, V&& v = dynamic::object);
+ template<class K, class V>
+ dynamic& setDefault(K&& k, V&& v);
+ // MSVC 2015 Update 3 needs these extra overloads because if V were a
+ // defaulted template parameter, it causes MSVC to consider v an rvalue
+ // reference rather than a universal reference, resulting in it not being
+ // able to find the correct overload to construct a dynamic with.
+ template<class K>
+ dynamic& setDefault(K&& k, dynamic&& v);
+ template<class K>
+ dynamic& setDefault(K&& k, const dynamic& v = dynamic::object);
/*
* Resizes an array so it has at n elements, using the supplied