[SERVER-17640] Add explicit operator bool to BSONElement Created: 17/Mar/15  Updated: 19/Sep/15  Resolved: 18/Mar/15

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 3.1.1

Type: Improvement Priority: Major - P3
Reporter: Mathias Stearn Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Quint Iteration 3.1.1
Participants:

 Comments   
Comment by Githook User [ 18/Mar/15 ]

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-17640 Add explict BSONElement::operator bool()

Makes it easier to check for a field's existence and use it in a single scan:
if (auto elem = myObj["foo"]) {
// Use elem
}
else {
// default behavior
}
Branch: master
https://github.com/mongodb/mongo/commit/78541981780b9d3608ce6d43167e230ed03c6444

Generated at Thu Feb 08 03:45:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.