败犬日报 2025-03-23
1. cpp 代码高性能课程
https://github.com/dendibakh/perf-ninja
带代码 + benchmark + 视频讲解。
2. 重载决议的一个例子
cpp
#include <cstdio>
template <typename T>
void f(T &&x) {
printf("1\n");
}
void f(const int &x) { printf("2\n"); }
int main() {
int x = 1;
f(x);
}
答案是 1,const int &x
不是完美匹配(多了个 const)。