- 簡單的 macro, 用來避免未實作的 copy constructor 跟 assignment constructor 被 compiler實作
- Code
#define DISALLOW_EVIL_CONSTRUCTORS(name) \
name(const name &); \
name &operator=(const name &) /* NOLINT */
- Sample: ABuffer.h
struct ABuffer : public RefBase { explicit ABuffer(size_t capacity); ABuffer(void *data, size_t capacity); ... private: DISALLOW_EVIL_CONSTRUCTORS(ABuffer);
- Reference:
沒有留言:
張貼留言