C++ 中文周刊 第96期
C++ 中文周刊 第96期
RSS https://github.com/wanghenshui/cppweeklynews/releases.atom
弄了个qq频道,手机qq点击进入
欢迎投稿,推荐或自荐文章/软件/资源等
0113
部门聚餐了延误了一下。本周没看视频
资讯
标准委员会动态/ide/编译器信息放在这里
编译器信息最新动态推荐关注hellogcc公众号 本周更新 2023-01-11 第184期
一个博客收集网站 https://swedencpp.se/blogs 英文c++的最新博客收集
文章
取对数
哎。倒腾cmake我头疼
有点意思。这种针对牛逼网卡的优化我感觉大厂都在做类似的玩意
又一个c++项目引入rust的。之前有火狐浏览器,clickhouse, redpanda,linux内核,唱衰一波,不过不要慌,c++程序员一时半会不会失业
看代码
constexpr auto get = [](auto value) {
if consteval {
return value;
} else {
auto result = 0;
asm("movl $42, %%eax\n" : "=r" (result) );
return result;
}
};
static_assert(0 == get(0));
static_assert(4 == get(4));
static_assert(2 == get(2));
consteval auto fn() {
return get(0);
}
int main(int argc, char**) {
assert(42 == get(0));
assert(42 == get(argc));
return fn();
}
希望大家身体健康,活得久一点,就能用到静态反射了
编译器标准库用到很多变量是两个下划线 下划线大写字母开头的。自己定义变量尽量别用
测了一下simdutdf在Zen4的表现,挺强的
blake3是不是就是simd加速的?
给oilshell设计的GC。没仔细看
optional做函数参数是十分不恰当的。这玩意只适合做返回值
QVarLengthArray类似vector,区别在于对小数据做SBO优化,且resize不会做额外的初始化动作。初始化动作是c++默认有的。很多场景来看是多余的,比如string。c++20/23做了许多修正
比如
std::unique_ptr<int[]> p3 = std::make_unique_for_overwrite<int[]>(100'000);
再比如string
// C++23
std::string s = ~~~;
auto oldSize = s.size();
s.resize_and_overwrite(100'000, [oldSize](char *buf, std::size_t count) {
// For starters, s will *reserve* enough space, without initializing it.
//
// - buf points to the string's storage (i.e. s.data()) *after* the reserve;
// - count is the 1st argument to resize_and_overwrite (100k), so
// we can re-use this function with different `count`s.
// Populate the range [buf, buf+count]. We can mutate the entirety of
// the string's buffer. But let's say we're just interested in populating
// the new contents -- from position oldSize up to count.
for (size_it i = oldSize; i < count; ++i)
buf[i] = generateData(i);
// Notes:
// - If we're growing, the newly created storage is *uninitialized*.
// Don't read from it!
//
// - The old contents are still there, and we can access them freely.
// If needed, carry `oldSize` manually, to identify where to start
// writing (and leave the old contents alone).
//
// - It is legal to write into buf[count],
// but it will be overwritten with \0 when we're done.
// We don't need to populate the *entire* buffer -- we may stop short!
// The returned value will be the new size of the string.
return actual_new_size;
});
QVarLengthArray不会做多余的初始化,请注意(不过QT这套东西会玩的越来越少了,大部分读者应该不玩QT)
基础知识,不会的可以去看《程序员的自我修养 链接/库》这本书
MSVC有两套coroutine API
// in <experimental/coroutine>
#ifndef _ALLOW_COROUTINE_ABI_MISMATCH
#pragma detect_mismatch("_COROUTINE_ABI", "1")
#endif // _ALLOW_COROUTINE_ABI_MISMATCH
// in <coroutine>
#ifndef _ALLOW_COROUTINE_ABI_MISMATCH
#pragma detect_mismatch("_COROUTINE_ABI", "2")
#endif // _ALLOW_COROUTINE_ABI_MISMATCH
使用 /std:c++20
和 /std:c++latest
,才会用最新的api,experimental是c++17旧的
又是Windows API,如何处理flags,我直接贴下面,不懂windows
Flag | Meaning | Recommendation |
---|---|---|
DISCONNECTED | No network interface detects any network | Treat as offline. |
NOTRAFFIC | An interface is connected, but it cannot send or receive network traffic. | Treat as offline. |
SUBNET/LOCALNETWORK | An interface has been configured to send traffic, but the system cannot confirm Internet connectivity. | Make one attempt to contact service. |
INTERNET | The system has confirmed access to Microsoft Internet sites. | Treat as fully online. |
没看懂
视频
没啥说的,之前讲过,#embed可以嵌入二进制,比如插个音乐,文本等等
开源项目需要人手
- asteria 一个脚本语言,可嵌入,长期找人,希望胖友们帮帮忙,也可以加群384042845和作者对线
- pika 一个nosql 存储, redis over rocksdb,非常需要人贡献代码胖友们, 感兴趣的欢迎加群294254078前来对线
新项目介绍/版本更新
没看懂这玩意是干什么的
相关文章
- Enscape 2.6激活版免费下载 安装教程
- Photoshop CS5软件下载及安装教程 PS全版本软件下载地址(包括最新的2023)
- Ps2018软件安装教程win PS全版本软件下载地址(包括最新的2023)
- PS 2021直装版下载安装教程
- Photoshop(Ps) CS6下载安装教程 PS全版本软件下载地址(包括最新的2023)
- ABAP 之 长文本READ_TEXT的使用方式
- 前言:
- rust引用和借用
- 聊聊损失函数1. 噪声鲁棒损失函数简析 & 代码实现
- RAID 10磁盘阵列实践
- 什么是 SAP ABAP 的 include structure
- ABAP include structure 的一个具体用法
- PS2023软件安装包下载Photoshop 2023软件安装教程Win
- 嵌入式:S3C2410与S3C2440的区别
- 分布式对象存储设计原理
- Webpack核心概念
- 蓝桥杯寒假集训第四天(全球变暖DFS)
- note
- webpack-notebook
- PHP CS Fixer 的使用