Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
internals: add BUILD_BUG_ON and DISALLOW_* macros
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Dec 13, 2011
1 parent 6192ca2 commit d496d52
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/node_internals.h
Expand Up @@ -24,6 +24,22 @@

namespace node {

// Triggers a compile-time error if the assertion fails.
// The assertion needs to be a constant expression.
#define BUILD_BUG_ON(cond) ((void) sizeof(char[1 - 2 * !!(cond)]))

// Disallow the copy constructor and assignment. Use it in the
// private: sections of your class.
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)

// Like DISALLOW_COPY_AND_ASSIGN but also disables the default
// constructor.
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
TypeName(); \
DISALLOW_COPY_AND_ASSIGN(TypeName)

#ifndef offset_of
// g++ in strict mode complains loudly about the system offsetof() macro
// because it uses NULL as the base address.
Expand Down

0 comments on commit d496d52

Please sign in to comment.