Monthly Read Posts in Jan 2018

C++17 constexpr everything (or as much as the compiler can)

Read More

正确地初始化 std::atomic_flag

根据标准文档的要求,std::atomic_flag 只有利用 ATOMIC_FLAG_INIT 初始化之后,才获得一个确定的初始状态。

现在假设我们要自己实现一个 spin-lock,那么只需要利用 std::atomic_flag 实现一个 spin-mutex:

Read More

Binding to Privately Inherited Member Functions

考虑代码

#include <functional>

Read More

Monthly Read Posts in Dec 2017

C++ 11 Concurrency: Part 1 & Part 2 & Part 3

Read More

自动为 enum 类型添加位运算操作符

有时候需要在 C++ 里用 enum (class) 表示 flags,进行基础的 bitwise 运算,而哪怕是支持自动到 underlying integer 转换的 traditional enum,也需要额外的 cast 才能实现,所以在需要的时候为 enum 添加位运算支持还是有一定市场的。

Read More

Monthly Read Posts in Nov 2017

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
CppCon 2014: Unicode in CPP

Read More

用 Wirshark 捕捉分析经过 localhost 的网络包

最近写 WinAntHttp 的时候需要用 Wireshark 捕捉并分析发往 mock server 的 http 请求。

然而因为 mock server 是直接跑在本机 localhost 上的,而在 Windows 上,发往 localhost 的网络包都不会经过网卡,所以 wireshark 基本无法捕捉。

Read More