Cpp Trivial

2020-03-16

A trivially copyable type is a type whose storage is contiguous (and thus its copy implies a trivial memory block copy, as if performed with memcpy), either cv-qualified or not....

Read More

Singleton Thread Safe

2020-02-21

最近重构rdsn代码,创建了一个logger_proxy类,发现一些单例的线程安全问题,记录如下。

一、懒汉式

最初通过继承singleton的方式来实现的单例,如下:

Read More

Google Refptr

2019-12-19

最近工作中发现了一个关于智能指针的=运算符重载的经典代码实现,记录一下:

  scoped_refptr& operator=(std::nullptr_t) {
 ...
      
Read More