Skip to content

Commit c038dcc

Browse files
committed
src: update DISALLOW_COPY_AND_ASSIGN() to c++11
Mark the matrix of copy/move constructor/assignment operator as deleted. Prevents the object from being copied around (the macro already did that pre-C++11), but also from being moved out.
1 parent 9f5800a commit c038dcc

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/node.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ class ArrayBufferAllocator : public ArrayBuffer::Allocator {
165165
virtual void Free(void* data, size_t length) override;
166166
private:
167167
ArrayBufferAllocator() {}
168-
ArrayBufferAllocator(const ArrayBufferAllocator&);
169-
void operator=(const ArrayBufferAllocator&);
168+
DISALLOW_COPY_AND_ASSIGN(ArrayBufferAllocator);
170169
};
171170

172171
ArrayBufferAllocator ArrayBufferAllocator::the_singleton;

src/node_file.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,8 @@ static void After(uv_fs_t *req) {
248248
struct fs_req_wrap {
249249
fs_req_wrap() {}
250250
~fs_req_wrap() { uv_fs_req_cleanup(&req); }
251-
// Ensure that copy ctor and assignment operator are not used.
252-
fs_req_wrap(const fs_req_wrap& req);
253-
fs_req_wrap& operator=(const fs_req_wrap& req);
254251
uv_fs_t req;
252+
DISALLOW_COPY_AND_ASSIGN(fs_req_wrap);
255253
};
256254

257255

src/util.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ namespace node {
3434
(node::OneByteString((isolate), (string), sizeof(string) - 1))
3535

3636
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
37-
void operator=(const TypeName&); \
38-
TypeName(const TypeName&)
37+
void operator=(const TypeName&) = delete; \
38+
void operator=(TypeName&&) = delete; \
39+
TypeName(const TypeName&) = delete; \
40+
TypeName(TypeName&&) = delete
3941

4042
#if defined(NDEBUG)
4143
# define ASSERT(expression)

0 commit comments

Comments
 (0)