diff options
author | Mathias Stearn <mathias@10gen.com> | 2018-04-09 16:28:14 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2018-04-18 15:20:34 -0400 |
commit | d976399cc97e4973cbd48191aa5730e8f01547a8 (patch) | |
tree | b3daf0d510c101ddc70472feeee925d0ef4c86a6 /src/mongo/bson/util | |
parent | 2a1b247b29fdb037222d451d92568c79cbb341ae (diff) | |
download | mongo-d976399cc97e4973cbd48191aa5730e8f01547a8.tar.gz |
SERVER-34396 Fail to compile if io manipulators like std::hex are passed to StringBuilder/str::stream
This includes a partial revert of 80f409d1311eb8d20251d17be474aff382538b84
(SERVER-34307) to address this bug.
Diffstat (limited to 'src/mongo/bson/util')
-rw-r--r-- | src/mongo/bson/util/builder.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/bson/util/builder.h b/src/mongo/bson/util/builder.h index f82ffccc3fa..ccf4cd183fd 100644 --- a/src/mongo/bson/util/builder.h +++ b/src/mongo/bson/util/builder.h @@ -455,6 +455,14 @@ public: return optional ? *this << *optional : *this << "(None)"; } + /** + * Fail to compile if passed an unevaluated function, rather than allow it to decay and invoke + * the bool overload. This catches both passing std::hex (which isn't supported by this type) + * and forgetting to add () when doing `stream << someFuntion`. + */ + template <typename R, typename... Args> + StringBuilderImpl& operator<<(R (*val)(Args...)) = delete; + void appendDoubleNice(double x) { const int prev = _buf.l; const int maxSize = 32; |