Skip to content

败犬日报 2025-05-08

1. decltype(auto) 推导引用类型

cpp
template <typename T>
decltype(auto) move_if_noexcept(T t) {
    if constexpr (std::is_nothrow_move_constructible_v<T> ||!std::is_copy_constructible_v<T>) {
        return std::move(t);
    } else {
        return static_cast<T const &>(t);
    }
}

这里返回值用 auto 不会推导成引用,导致 copy 或 move。这时候就要用 decltype(auto)

2. 鱼和熊掌不可兼得——LLVM 条件常量传播优化的设计与妥协 - GnSight的文章 - 知乎

https://zhuanlan.zhihu.com/p/1897682406544234330

3. cmake 怎么生成 msvc 的 compile commands

ninja 可以,但是要配置 msvc 路径(有个自动找 msvc 工具链的 cmake,https://github.com/aminya/project_options)。

也可以 用 vs 插件 clang power tools,可以从 sln 生成。

4. 推荐一个科技类新闻简报

https://tldr.tech/