summaryrefslogtreecommitdiff
path: root/src/mongo/bson/bsonobjbuilder.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/bson/bsonobjbuilder.h')
-rw-r--r--src/mongo/bson/bsonobjbuilder.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mongo/bson/bsonobjbuilder.h b/src/mongo/bson/bsonobjbuilder.h
index ef92065d9a0..35402a3a3ed 100644
--- a/src/mongo/bson/bsonobjbuilder.h
+++ b/src/mongo/bson/bsonobjbuilder.h
@@ -666,9 +666,10 @@ public:
* The returned BSONObj will free the buffer when it is finished.
* @return owned BSONObj
*/
+ template <typename BSONTraits = BSONObj::DefaultSizeTrait>
BSONObj obj() {
massert(10335, "builder does not own memory", owned());
- auto out = done();
+ auto out = done<BSONTraits>();
out.shareOwnershipWith(_b.release());
return out;
}
@@ -678,8 +679,9 @@ public:
scope -- very important to keep in mind. Use obj() if you
would like the BSONObj to last longer than the builder.
*/
+ template <typename BSONTraits = BSONObj::DefaultSizeTrait>
BSONObj done() {
- return BSONObj(_done());
+ return BSONObj(_done(), BSONTraits{});
}
// Like 'done' above, but does not construct a BSONObj to return to the caller.
@@ -692,7 +694,7 @@ public:
Intended use case: append a field if not already there.
*/
BSONObj asTempObj() {
- BSONObj temp(_done());
+ BSONObj temp(_done(), BSONObj::LargeSizeTrait{});
_b.setlen(_b.len() - 1); // next append should overwrite the EOO
_b.reserveBytes(1); // Rereserve room for the real EOO
_doneCalled = false;