Dealing With Multiple Types As a Category
Macro ENSURE()
from KBase can ‘capture’ variables by outputing their content to the internal stringtream, provided the type of captured variables has overloaded operator<<()
.
Macro ENSURE()
from KBase can ‘capture’ variables by outputing their content to the internal stringtream, provided the type of captured variables has overloaded operator<<()
.
Clearer interfaces with optional
optional<T>
介绍 & 简单使用例子
CppCon 2015: John R. Bandela “Simple, Extensible Pattern Matching in C++14”
一个轻量级的 pattern matching 库简要介绍。
CppCon 2015: Greg Miller “Time Programming Fundamentals”
Google 内部实现的一个处理 date-time 的轮子。
不过讲道理,这块内容还不如关注一下之前 monthly read posts 里出现的这篇 里提到的 date library。
看起来差不多会在 C++ 20 引入
When MSDN says NULL, is it okay to use nullptr?
Short anwser: YES.
自从 Windows 10 提供 WSL 之后,在 Windows 上运行 Linux CLI 程序并不是一个复杂的事情;然而俗话说饱暖思淫欲,既然可以做到在 Windows 上跑 Linux CLI 了,下一步自然想的是在 Windows 上跑 Linux GUI 程序。
之所以要跑 GUI 是因为,无论是 vscode 还是 CLion,写 C++ 的体验都比在 terminal 里开一个 vim 要好太多了,无论你是花了多少时间配置了 .vimrc
,在 CLion 面前都是战五渣。更何况我买了 Jetbrains 的 All product license,不用用难道留着过年吗。
这里先解答两个常见疑问:
Q:为什么不直接在虚拟机里使用?
A:因为 Linux 对 4K 屏原生支持太糟糕。哪怕 Mint 提供了 double scaling,解决了一些外观上的问题,我在 4K 的环境下一开 vscode 程序就崩溃,而且运行操作明显掉帧。
另外一个问题是,单纯的虚拟机操作和外界宿主太隔离,等于我得配置两套完全一样的环境(比如浏览器,常见的应用,甚至 SS 等),而且和宿主的交互非常不够便利。
Q:为什么不买 macbook?
A:??你是认真的么?OS X 那么垃圾的系统。再说我要写 C++ server-end 的代码,要是可以用 OS X 我为什么不直接在 Windows 上跑?
另外有一个剧透:我尝试过运行 WSL 里的 Linux GUI 程序,例如 CLion,但是目前 WSL 的文件系统性能过于糟糕,CLion 一个劲的冒错误提示,所以,下面的环境假定是虚拟机里的 Linux 或者一台单独的 Linux 设备。
CppCon 2015: Richard Powell “Intro to the C++ Object Model”
基本覆盖了 POD,无需函数类,单继承的情况,扫盲效果俱佳。
至于为什么没有包含 multiple inheritance / virtual inheritance,作者说自己不是很 condifent with that。
讲道理,MI / VI 在一般的设计里都会尽量避免,而且各种乱七八糟的 case 很多,这里不涉及反而是个正确的做法。
首先,我很赞同文中作者对于 assertion 是 guarantees given by the author of a piece of code to himself/herself 但是接下来的大部观点都不赞同。
比如作者认为不应该 assert on precodintions & postconditions,因为 assertion 是 for implementation details,这个思路其实不对。
关于 assertion,目前看过最好的阐述还是 Writing Solid Code,推荐去阅读这个。
这篇 post 展示了 constexpr functions 错误报告的常见手段:抛异常。
这个在之前的某个 cppcon talk 里有专门的介绍。
另外,文中更进一步,抽出专门的 constexpr validation functions,并通过 comma operator 串联。
C++ 14 支持多句之后,连 comma operatos 都可以免掉了。
但凡有点历史的东西,在演进到一个新的阶段时,总会总结一套新的 practices 然后冠之以 modern,例如 modern C++,还有今天的主题 —— modern CMake。
上周花了一点时间稍微研究了一下所谓的 modern cmake,然后将 KBase 在 POSIX 上的 cmake 文件都按照 modern cmake 的做法做了修改,结果可见此
Go is a quite awesome programming language for building network applications. So I built my own HTTP proxy server using go last week.
To grasp the essence of how HTTP proxy server works, I choosed to implement it on TCP transport layer, forwarding TCP traffic directly.
Essentially, it runs a server, accepting incoming TCP connections and from which the server extracts target host of a request by parsing HTTP protocol messages. The server then establishes a connection to the target host, and finally operates as an intermedia, forwarding traffic from one host to another.
Implementing a TCP server which is able to handle concurrent requests uing go is easier than you thought: just runs a loop to accept requests, launching a new goroutine for each new connection:
1 | type Server struct { |
当前行业招聘的不靠谱,招揽优秀人员的难度大。
脱颖而出的核心:良好的阅读习惯 + Github 项目
这里说的两年是针对应届生来说的,对于已经工作的人来说,可以当作是虚指。
不过文中提到的,拥抱变化的三个核心点:
颇有道理。
如何做技术选型
A brief introduction to Linux I/O stack.
这篇 post 的质量在国内技术博客里算是少有的干货。
另,关于 page cache 和 buffer cache 的最新的内容,可以参考 Robert Love 在 quora 上的一个回答
CppCon 2015: John Farrier “Demystifying Floating Point”
工程实践上使用浮点数(IEEE-754)需要注意的一些坑。
看之前最好翻一下 CSAPP 中关于浮点数 IEEE-754 模型的基础知识