Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Commit 9d212e4

Browse files
committed
SERVER-17311 Ensure BSONObj, RecordData, and SharedBuffer are noexcept moveable
1 parent 928aabb commit 9d212e4

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

src/mongo/bson/bsonobj.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <list>
3434
#include <set>
3535
#include <string>
36+
#include <type_traits>
3637
#include <utility>
3738
#include <vector>
3839

@@ -591,6 +592,9 @@ class BSONObj {
591592
ConstSharedBuffer _ownedBuffer;
592593
};
593594

595+
MONGO_STATIC_ASSERT(std::is_nothrow_move_constructible_v<BSONObj>);
596+
MONGO_STATIC_ASSERT(std::is_nothrow_move_assignable_v<BSONObj>);
597+
594598
std::ostream& operator<<(std::ostream& s, const BSONObj& o);
595599
std::ostream& operator<<(std::ostream& s, const BSONElement& e);
596600

src/mongo/db/storage/record_data.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
#pragma once
3131

32+
#include <type_traits>
33+
3234
#include "mongo/bson/bsonobj.h"
3335
#include "mongo/util/shared_buffer.h"
3436

@@ -98,4 +100,7 @@ class RecordData {
98100
SharedBuffer _ownedData;
99101
};
100102

103+
MONGO_STATIC_ASSERT(std::is_nothrow_move_constructible_v<RecordData>);
104+
MONGO_STATIC_ASSERT(std::is_nothrow_move_assignable_v<RecordData>);
105+
101106
} // namespace mongo

src/mongo/dbtests/SConscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ if not has_option('noshell') and usemozjs:
8585
'mock_dbclient_conn_test.cpp',
8686
'mock_replica_set_test.cpp',
8787
'multikey_paths_test.cpp',
88-
'shared_buffer.cpp',
88+
'shared_buffer_test.cpp',
8989
'pdfiletests.cpp',
9090
'plan_executor_invalidation_test.cpp',
9191
'plan_ranking.cpp',

src/mongo/dbtests/shared_buffer.cpp renamed to src/mongo/dbtests/shared_buffer_test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929

3030
#include "mongo/platform/basic.h"
3131

32+
#include "mongo/util/shared_buffer.h"
33+
3234
#include "mongo/base/string_data.h"
35+
3336
#include "mongo/unittest/unittest.h"
34-
#include "mongo/util/shared_buffer.h"
3537

3638
namespace mongo {
3739
namespace {

src/mongo/util/shared_buffer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@
3030
#pragma once
3131

3232
#include <algorithm>
33+
#include <type_traits>
3334

3435
#include <boost/intrusive_ptr.hpp>
3536

3637
#include "mongo/platform/atomic_word.h"
38+
3739
#include "mongo/util/allocator.h"
3840
#include "mongo/util/assert_util.h"
3941

@@ -177,6 +179,9 @@ class SharedBuffer {
177179
boost::intrusive_ptr<Holder> _holder;
178180
};
179181

182+
MONGO_STATIC_ASSERT(std::is_nothrow_move_constructible_v<SharedBuffer>);
183+
MONGO_STATIC_ASSERT(std::is_nothrow_move_assignable_v<SharedBuffer>);
184+
180185
inline void swap(SharedBuffer& one, SharedBuffer& two) {
181186
one.swap(two);
182187
}

0 commit comments

Comments
 (0)