Skip to content
败犬日报 2025-10-16

败犬日报 2025-10-16

1. 函数指针做了类型擦除吗

没有,函数指针只能接受函数指针。函数类型擦除指的是一个类型(最典型的是 std::function)可以接受函数指针、lambda 等各种东西,而且能够正常调用 operator()

另外,模板也不是类型擦除,因为模板不是一个确定的类型(重点,“一个”)。

2. hyprland

https://hypr.land/hall_of_fame/

桌面玩得太花了,看一乐。

3. C++17 之前类模板怎么方便地接带捕获 lambda

std::make_pair 那样搞个函数即可。

cpp
#include <utility>

template <typename T>
struct Wrapper {
    T func;
    Wrapper(T&& f) : func(std::forward<T>(f)) {}
};

template <typename T>
Wrapper<T> make_wrapper(T&& f) {
    return Wrapper<T>(std::forward<T>(f));
}

int main() {
    int x = 10;
    Wrapper w{[x] { return x; }};               // 需要 C++17 CTAD
    auto w2 = make_wrapper([x] { return x; });  // C++11 or 14
}

4. std::tuple 为什么递归继承实现(文章)

https://www.zhihu.com/question/668086900/answer/1960362682067714736

注意其中 C++20 - 23 的 lambda 捕获实现做不到 no_unique_address 的效果。std::pair, std::tuple 利用空基类优化来实现 no_unique_address:

cpp
#include <iostream>

struct Empty {};

int main() {
    printf("%ld\n", sizeof(std::tuple<Empty, int>));  // 输出 4
}

5. 点灯游戏

https://dailyakari.com/

6. 如何看待《我的世界》Java 版性能超越基岩版?(知乎问题)

https://www.zhihu.com/question/1961940831893164125

其实讨论不出什么。要比性能的话要先按照性能优化的需求投入开发人力,写 💩 山的话啥语言都慢。

7. 群友(面试官)线上面试遇到交换机了

他的每个回答都先懵逼十几秒钟然后迅速侃侃而谈。

所以线下面试可能会越来越多。

8. c、c++运行速度快,是语法决定的还是编译器决定的?(文章)

https://www.zhihu.com/question/662554502/answer/1961219439233053978