diff options
Diffstat (limited to 'src/mongo/bson/bsonobjbuilder.h')
-rw-r--r-- | src/mongo/bson/bsonobjbuilder.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/bson/bsonobjbuilder.h b/src/mongo/bson/bsonobjbuilder.h index 3a3f91a60cf..74593287942 100644 --- a/src/mongo/bson/bsonobjbuilder.h +++ b/src/mongo/bson/bsonobjbuilder.h @@ -35,6 +35,7 @@ #pragma once #include <cmath> +#include <cstdint> #include <limits> #include <map> @@ -45,6 +46,7 @@ #include "mongo/bson/bsonmisc.h" #include "mongo/bson/bsonobj.h" #include "mongo/platform/decimal128.h" +#include "mongo/stdx/type_traits.h" #include "mongo/util/itoa.h" namespace mongo { @@ -270,6 +272,19 @@ public: return *this; } + /** + * Append a NumberLong (if int64_t isn't the same as long long) + */ + template <typename Int64_t, + typename = stdx::enable_if_t<std::is_same<Int64_t, int64_t>::value && + !std::is_same<int64_t, long long>::value>> + BSONObjBuilder& append(StringData fieldName, Int64_t n) { + _b.appendNum((char)NumberLong); + _b.appendStr(fieldName); + _b.appendNum(n); + return *this; + } + /** appends a number. if n < max(int)/2 then uses int, otherwise long long */ BSONObjBuilder& appendIntOrLL(StringData fieldName, long long n) { // extra () to avoid max macro on windows |