diff options
author | Drew Paroski <andrew.paroski@10gen.com> | 2020-04-21 16:46:00 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-23 16:16:39 +0000 |
commit | 8981010cf5d5a2d529b338880186ed8f51526396 (patch) | |
tree | 2aad52120ef2938073512cc210d4200e08747e34 /src/mongo/bson | |
parent | f9fb5f85c64adbcad203705d4972180808d48abb (diff) | |
download | mongo-8981010cf5d5a2d529b338880186ed8f51526396.tar.gz |
SERVER-30044 Delete const&& versions of BSONComparatorInterfaceBase's make* methods
Diffstat (limited to 'src/mongo/bson')
-rw-r--r-- | src/mongo/bson/bson_comparator_interface_base.h | 28 | ||||
-rw-r--r-- | src/mongo/bson/bsonelement_comparator_interface.h | 21 | ||||
-rw-r--r-- | src/mongo/bson/bsonobj_comparator_interface.h | 20 |
3 files changed, 55 insertions, 14 deletions
diff --git a/src/mongo/bson/bson_comparator_interface_base.h b/src/mongo/bson/bson_comparator_interface_base.h index 1f412438e76..8f918062a50 100644 --- a/src/mongo/bson/bson_comparator_interface_base.h +++ b/src/mongo/bson/bson_comparator_interface_base.h @@ -226,40 +226,56 @@ public: * Returns a function object which computes whether one BSONObj is less than another under this * comparator. This comparator must outlive the returned function object. */ - LessThan makeLessThan() const { + LessThan makeLessThan() const& { return LessThan(this); } + LessThan makeLessThan() const&& = delete; + /** * Returns a function object which computes whether one BSONObj is equal to another under this * comparator. This comparator must outlive the returned function object. */ - EqualTo makeEqualTo() const { + EqualTo makeEqualTo() const& { return EqualTo(this); } + EqualTo makeEqualTo() const&& = delete; + protected: constexpr BSONComparatorInterfaceBase() = default; - Set makeSet(std::initializer_list<T> init = {}) const { + Set makeSet(std::initializer_list<T> init = {}) const& { return Set(init, LessThan(this)); } - UnorderedSet makeUnorderedSet(std::initializer_list<T> init = {}) const { + Set makeSet(std::initializer_list<T> init = {}) const&& = delete; + + UnorderedSet makeUnorderedSet(std::initializer_list<T> init = {}) const& { return UnorderedSet(init, 0, Hasher(this), EqualTo(this)); } + UnorderedSet makeUnorderedSet(std::initializer_list<T> init = {}) const&& = delete; + template <typename ValueType> - Map<ValueType> makeMap(std::initializer_list<std::pair<const T, ValueType>> init = {}) const { + Map<ValueType> makeMap(std::initializer_list<std::pair<const T, ValueType>> init = {}) const& { return Map<ValueType>(init, LessThan(this)); } template <typename ValueType> + Map<ValueType> makeMap(std::initializer_list<std::pair<const T, ValueType>> init = {}) const&& = + delete; + + template <typename ValueType> UnorderedMap<ValueType> makeUnorderedMap( - std::initializer_list<std::pair<const T, ValueType>> init = {}) const { + std::initializer_list<std::pair<const T, ValueType>> init = {}) const& { return UnorderedMap<ValueType>(init, 0, Hasher(this), EqualTo(this)); } + template <typename ValueType> + UnorderedMap<ValueType> makeUnorderedMap( + std::initializer_list<std::pair<const T, ValueType>> init = {}) const&& = delete; + /** * Hashes 'objToHash', respecting the equivalence classes given by 'stringComparator'. * diff --git a/src/mongo/bson/bsonelement_comparator_interface.h b/src/mongo/bson/bsonelement_comparator_interface.h index 28877d0473f..673ea06a802 100644 --- a/src/mongo/bson/bsonelement_comparator_interface.h +++ b/src/mongo/bson/bsonelement_comparator_interface.h @@ -60,37 +60,50 @@ public: * Constructs a BSONEltSet whose equivalence classes are given by this comparator. This * comparator must outlive the returned set. */ - Set makeBSONEltSet(std::initializer_list<BSONElement> init = {}) const { + Set makeBSONEltSet(std::initializer_list<BSONElement> init = {}) const& { return makeSet(init); } + Set makeBSONEltSet(std::initializer_list<BSONElement> init = {}) const&& = delete; + /** * Constructs a BSONEltUnorderedSet whose equivalence classes are given by this * comparator. This comparator must outlive the returned set. */ - UnorderedSet makeBSONEltUnorderedSet(std::initializer_list<BSONElement> init = {}) const { + UnorderedSet makeBSONEltUnorderedSet(std::initializer_list<BSONElement> init = {}) const& { return makeUnorderedSet(init); } + UnorderedSet makeBSONEltUnorderedSet(std::initializer_list<BSONElement> init = {}) const&& = + delete; + /** * Constructs an ordered map from BSONElement to type ValueType whose ordering is given by this * comparator. This comparator must outlive the returned map. */ template <typename ValueType> Map<ValueType> makeBSONEltIndexedMap( - std::initializer_list<std::pair<const BSONElement, ValueType>> init = {}) const { + std::initializer_list<std::pair<const BSONElement, ValueType>> init = {}) const& { return makeMap(init); } + template <typename ValueType> + Map<ValueType> makeBSONEltIndexedMap( + std::initializer_list<std::pair<const BSONElement, ValueType>> init = {}) const&& = delete; + /** * Constructs an unordered map from BSONElement to type ValueType whose ordering is given by * this comparator. This comparator must outlive the returned map. */ template <typename ValueType> UnorderedMap<ValueType> makeBSONEltIndexedUnorderedMap( - std::initializer_list<std::pair<const BSONElement, ValueType>> init = {}) const { + std::initializer_list<std::pair<const BSONElement, ValueType>> init = {}) const& { return makeUnorderedMap(init); } + + template <typename ValueType> + UnorderedMap<ValueType> makeBSONEltIndexedUnorderedMap( + std::initializer_list<std::pair<const BSONElement, ValueType>> init = {}) const&& = delete; }; using BSONEltSet = BSONComparatorInterfaceBase<BSONElement>::Set; diff --git a/src/mongo/bson/bsonobj_comparator_interface.h b/src/mongo/bson/bsonobj_comparator_interface.h index 3b7bea8e30d..e0be34816d1 100644 --- a/src/mongo/bson/bsonobj_comparator_interface.h +++ b/src/mongo/bson/bsonobj_comparator_interface.h @@ -57,37 +57,49 @@ public: * Constructs a BSONObjSet whose equivalence classes are given by this comparator. This * comparator must outlive the returned set. */ - Set makeBSONObjSet(std::initializer_list<BSONObj> init = {}) const { + Set makeBSONObjSet(std::initializer_list<BSONObj> init = {}) const& { return makeSet(init); } + Set makeBSONObjSet(std::initializer_list<BSONObj> init = {}) const&& = delete; + /** * Constructs a BSONObjUnorderedSet whose equivalence classes are given by this * comparator. This comparator must outlive the returned set. */ - UnorderedSet makeBSONObjUnorderedSet(std::initializer_list<BSONObj> init = {}) const { + UnorderedSet makeBSONObjUnorderedSet(std::initializer_list<BSONObj> init = {}) const& { return makeUnorderedSet(init); } + UnorderedSet makeBSONObjUnorderedSet(std::initializer_list<BSONObj> init = {}) const&& = delete; + /** * Constructs an ordered map from BSONObj to type ValueType whose ordering is given by this * comparator. This comparator must outlive the returned map. */ template <typename ValueType> Map<ValueType> makeBSONObjIndexedMap( - std::initializer_list<std::pair<const BSONObj, ValueType>> init = {}) const { + std::initializer_list<std::pair<const BSONObj, ValueType>> init = {}) const& { return makeMap(init); } + template <typename ValueType> + Map<ValueType> makeBSONObjIndexedMap( + std::initializer_list<std::pair<const BSONObj, ValueType>> init = {}) const&& = delete; + /** * Constructs an unordered map from BSONObj to type ValueType whose ordering is given by this * comparator. This comparator must outlive the returned map. */ template <typename ValueType> UnorderedMap<ValueType> makeBSONObjIndexedUnorderedMap( - std::initializer_list<std::pair<const BSONObj, ValueType>> init = {}) const { + std::initializer_list<std::pair<const BSONObj, ValueType>> init = {}) const& { return makeUnorderedMap(init); } + + template <typename ValueType> + UnorderedMap<ValueType> makeBSONObjIndexedUnorderedMap( + std::initializer_list<std::pair<const BSONObj, ValueType>> init = {}) const&& = delete; }; using BSONObjSet = BSONComparatorInterfaceBase<BSONObj>::Set; |