Browse Source

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.
archived-io.js-v0.12
Ben Noordhuis 10 years ago
parent
commit
c038dcc360
  1. 3
      src/node.cc
  2. 4
      src/node_file.cc
  3. 6
      src/util.h

3
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;

4
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);
};

6
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)

Loading…
Cancel
Save