diff options
author | Matt Broadstone <mbroadst@mongodb.com> | 2022-02-01 14:55:44 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-02-01 16:12:55 +0000 |
commit | 1cc5df724ab48604e19a8b2f3703563c553b1ba0 (patch) | |
tree | 68493e81ddd2bc3fc790dd626ad2de689fef405c /src/mongo/bson/bsonobjbuilder.h | |
parent | b2098c676bdc64e3194734fa632b133c47496646 (diff) | |
download | mongo-1cc5df724ab48604e19a8b2f3703563c553b1ba0.tar.gz |
SERVER-62609 Represent the w parameter of WriteConcernOptions as a variant
Diffstat (limited to 'src/mongo/bson/bsonobjbuilder.h')
-rw-r--r-- | src/mongo/bson/bsonobjbuilder.h | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/mongo/bson/bsonobjbuilder.h b/src/mongo/bson/bsonobjbuilder.h index c4b578e5f35..be826d5a824 100644 --- a/src/mongo/bson/bsonobjbuilder.h +++ b/src/mongo/bson/bsonobjbuilder.h @@ -539,9 +539,17 @@ public: * Append a map of values as a sub-object. * Note: the keys of the map should be StringData-compatible (i.e. strings). */ - template <class K, class T> - Derived& append(StringData fieldName, const std::map<K, T>& vals); + TEMPLATE(typename Map) + REQUIRES(std::is_convertible_v<decltype(std::declval<Map>().begin()->first), StringData>) + Derived& append(StringData fieldName, const Map& map) { + typename std::remove_reference<Derived>::type bob; + for (auto&& [k, v] : map) { + bob.append(k, v); + } + append(fieldName, bob.obj()); + return static_cast<Derived&>(*this); + } /** Append a range of values between two iterators. */ template <class It> @@ -859,7 +867,6 @@ public: UniqueBSONObjBuilder(UniqueBSONObjBuilder&&) = default; UniqueBSONObjBuilder(const UniqueBSONObjBuilder&) = delete; - UniqueBSONObjBuilder& operator=(UniqueBSONObjBuilder&&) = default; UniqueBSONObjBuilder& operator=(const UniqueBSONObjBuilder&) = delete; ~UniqueBSONObjBuilder() { @@ -1117,18 +1124,6 @@ inline Derived& BSONObjBuilderBase<Derived, B>::append(StringData fieldName, return append(fieldName, vals.begin(), vals.end()); } -template <class Derived, class BufBuilderType> -template <class K, class T> -inline Derived& BSONObjBuilderBase<Derived, BufBuilderType>::append(StringData fieldName, - const std::map<K, T>& vals) { - typename std::remove_reference<Derived>::type bob; - for (typename std::map<K, T>::const_iterator i = vals.begin(); i != vals.end(); ++i) { - bob.append(i->first, i->second); - } - append(fieldName, bob.obj()); - return static_cast<Derived&>(*this); -} - template <class Derived, class B> template <class It> inline Derived& BSONObjBuilderBase<Derived, B>::append(StringData fieldName, It begin, It end) { |