公众号
qq群 点击进入
RSS https://github.com/wanghenshui/cppweeklynews/releases.atom
欢迎投稿,推荐或自荐文章/软件/资源等评论区留言
本期文章由 黄亮Anthony HNY 赞助
2024 01 07
标准委员会动态/ide/编译器信息放在这里
编译器信息最新动态推荐关注hellogcc公众号 本周更新 2024-01-03 第235期
看个乐呵, 了解概念对于CPU运行还是有点理解的
LLVM知识,学吧,都是知识,早晚碰到
jemalloc最新知识,学吧
编译很慢,怎么抓?
#include <fmt/core.h>
int main() {
fmt::print("Hello, {}!\n", "world");
}
// c++ -ftime-trace -c hello.cc -I include -std=c++20
ftime-trace的数据可以放到浏览器的tracing里,比如 chrome://tracing/
firefox可以用这个 https://profiler.firefox.com/from-url/https%3A%2F%2Fvitaut.net%2Ffiles%2F2024-hello-before.json/marker-chart/?globalTrackOrder=0&hiddenLocalTracksByPid=65312-fwx3&thread=0&timelineType=category&v=10
我没看懂他是怎么分析出头文件的耗时的,总之,把string前向声明一下
#ifdef FMT_BEGIN_NAMESPACE_STD
FMT_BEGIN_NAMESPACE_STD
template <typename Char>
struct char_traits;
template <typename T>
class allocator;
template <typename Char, typename Traits, typename Allocator>
class basic_string;
FMT_END_NAMESPACE_STD
#else
# include <string>
#endif
但是这种接口编译不过
template <typename... T>
FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
-> basic_string<char> {
return vformat(fmt, fmt::make_format_args(args...));
}
因为basic_string<char>
找不到实现,怎么破?
template <typename... T, typename Char = char>
FMT_NODISCARD FMT_INLINE auto format(format_string<T...> fmt, T&&... args)
-> basic_string<Char> {
return vformat(fmt, fmt::make_format_args(args...));
}
然后这个操作就省掉了大量编译时间
结构是这样的
class WidgetContainer : IWidgetCallback
{
//
};
auto widget = std::shared_ptr<Widget>(new Widget(this));
能不能换成make_shared?不能,因为是private继承
怎么破?
auto widget = std::make_shared<Widget>(
static_cast<IWidgetCallback*>(this));
struct foo {
int a{};
int b{};
int c{};
};
static_assert(3 == std::size(std::meta::nonstatic_data_members_of(^foo)));
deque msvc实现有坑爹的地方
gcc | clang | msvc | |
---|---|---|---|
Block size | as many as fit in 512 bytes but at least 1 element | as many as fit in 4096 bytes but at least 16 elements | power of 2 that fits in 16 bytes but at least 1 element |
Initial map size | 8 | 2 | 8 |
Map growth | 2× | 2× | 2× |
Map shrinkage | On request | On request | On request |
Initial first/last | Center | Start | Start |
Members | block** map; size_t map_size; iterator first; iterator last; |
block** map; block** first_block; block** last_block; block** end_block; size_t first; size_t size; |
block** map; size_t map_size; size_t first; size_t size; |
Map layout | counted array | simple_deque | counted array |
Valid range | Pair of iterators | Start and count | Start and count |
Iterator | T* current; T* current_block_begin; T* current_block_end; block** current_block; |
T* current; block** current_block; | deque* parent; size_t index; |
begin()/end() | Copy first and last. | Break first and first + size into block index and offset. | Break first and first + size into block index and offset. |
Spare blocks | Aggressively pruned | Keep one on each end | Keep all |
block size太小了
介绍协程并写了个co curl 有点意思,视频我也传B站了 https://www.bilibili.com/video/BV1NG411B7Fy/
代码在这里 https://github.com/hanickadot/co_curl
#include <fmt/chrono.h>
int main() {
fmt::print("{}\n", std::chrono::days(42)); // prints "42d"
}
编译期物理计算的
https://job.toutiao.com/s/i8Tv36Jf 字节杭州虚拟机v8研发
字节的音视频团队,主要负责剪映上的音视频/非线性编辑相关工作,业务前景也比较好,目前有三个方向的岗位
base北上广深杭都可以,薪资open,有兴趣的同学可以通过链接投递
新的一年开始了,本周刊也走过了三个年头,希望大家都健康我也继续保持更新下去
如果有疑问评论最好在上面链接到评论区里评论,这样方便搜索,微信公众号有点封闭/知乎吞评论