双语

Total posts: 1

DIY std::optional: Using Universal References in C++

This blog was written entirely because of the item Familiarize yourself with alternatives to overloading on universal references in Effcetive Morden C++. We start with a practical problem trying to emulate std::optional in C++14, because optional monads are a good paradigm for expressing values ​​that may be null, rather than assuming everything is maybe null which can easily break through the type system. 写下这篇文章完全是因为看到了 Effcetive Morden C++ 中的熟悉通用引用重载的替代方法。我们从一个现实的问题开始,即在 C++14 尝试模拟 std::optional,因为 optional 是表达可能为空的值的时候一个很好的范式,而不是假定一切都可能为 null 并轻易击穿类型系统。