From c038dcc360cb5e72c5891d1ef59640f5c3fa76b8 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 22 Oct 2014 04:33:01 +0200 Subject: [PATCH] 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. --- src/node.cc | 3 +-- src/node_file.cc | 4 +--- src/util.h | 6 ++++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/node.cc b/src/node.cc index eaf2277579..6aaf306827 100644 --- a/src/node.cc +++ b/src/node.cc @@ -165,8 +165,7 @@ class ArrayBufferAllocator : public ArrayBuffer::Allocator { virtual void Free(void* data, size_t length) override; private: ArrayBufferAllocator() {} - ArrayBufferAllocator(const ArrayBufferAllocator&); - void operator=(const ArrayBufferAllocator&); + DISALLOW_COPY_AND_ASSIGN(ArrayBufferAllocator); }; ArrayBufferAllocator ArrayBufferAllocator::the_singleton; diff --git a/src/node_file.cc b/src/node_file.cc index 86474b75fa..dec90b5291 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -248,10 +248,8 @@ static void After(uv_fs_t *req) { struct fs_req_wrap { fs_req_wrap() {} ~fs_req_wrap() { uv_fs_req_cleanup(&req); } - // Ensure that copy ctor and assignment operator are not used. - fs_req_wrap(const fs_req_wrap& req); - fs_req_wrap& operator=(const fs_req_wrap& req); uv_fs_t req; + DISALLOW_COPY_AND_ASSIGN(fs_req_wrap); }; diff --git a/src/util.h b/src/util.h index 4f0de82d56..7bafe79e30 100644 --- a/src/util.h +++ b/src/util.h @@ -34,8 +34,10 @@ namespace node { (node::OneByteString((isolate), (string), sizeof(string) - 1)) #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - void operator=(const TypeName&); \ - TypeName(const TypeName&) + void operator=(const TypeName&) = delete; \ + void operator=(TypeName&&) = delete; \ + TypeName(const TypeName&) = delete; \ + TypeName(TypeName&&) = delete #if defined(NDEBUG) # define ASSERT(expression)