Tag Archives: c++11

一个关于 Pimpl 的小技巧

使用 Pimpl 很多时候是必须的,ABI 兼容的时候基本都要靠它。在 C++ 11 当中,通过 default member initializer 可以实现很多有趣的效果,加上宏的话很多时候可以利用来实现 Metadata 的效果,例如: #define PROPERTY(NAME) \ Property NAME{this, #NAME}; class Registry { friend class Property; public: int& getValueByName(const std::string &name) { return *values_[name]; } protected: void registerValue(const std::string name, int* … Continue reading

Posted in Linux | Tagged , , | Leave a comment