败犬日报 2025-11-20
1. 延迟初始化
类 A 有个成员 b,在 A 初始化时还不能确定 b 的构造参数,怎么做?
可以把 b 用 std::optional 或者 std::unique_ptr 套一下。
2. /usr 是否曾经是 user 的简写
网上很多人说 /usr 一开始表示 user,后来 /usr 内容转移到 /home,于是给 usr 一个 Unix System Resources 的解释。
但是没有权威资料证明 usr 是 user,只能说大概率是这样。
维基有 /usr 的由来,但没说全称是什么 https://en.wikipedia.org/wiki/Unix_filesystem#Principles:
In the original Bell Labs Unix, a two-disk setup was customary, where the first disk contained startup programs, while the second contained users' files and programs. This second disk was mounted at the empty directory named usr on the first disk, causing the two disks to appear as one filesystem, with the second disk’s contents viewable at /usr.
在最初的贝尔实验室 Unix 系统中,通常采用双磁盘配置,第一块磁盘存放启动程序,第二块磁盘存放用户文件和程序。第二块磁盘挂载在第一块磁盘上名为 /usr 的空目录下,使得两块磁盘看起来像是一个文件系统,用户可以通过 /usr 访问第二块磁盘的内容。
(就算 /usr 存放 user 文件,也不能证实 /usr 是 user)
而群友又翻了 System V 的手册,有的东西确实会把 user 缩写成 usr,比如 SIGUSR1。