V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  bluearc  ›  全部回复第 1 页 / 共 7 页
回复总数  128
1  2  3  4  5  6  7  
8 天前
回复了 Plumes 创建的主题 Windows Windows 又在犯大病了
onedrive 默认同步策略就这样,把你本地的文件上传到云,然后再把你本地的删掉,美其名曰节省本地空间,等你想用的时候还得先下文件,更别提 onedrive 在国内的网络问题(最近好了,简直私募了
8 天前
回复了 nealHuang 创建的主题 Apple 发现 Mac 自带了网络质量测试工具
==== SUMMARY ====
Uplink capacity: 24.741 Mbps
Downlink capacity: 407.141 Mbps
Responsiveness: High (48.560 milliseconds | 1235 RPM)
Idle Latency: 25.708 milliseconds | 2333 RPM
@vcmt 如果真到那时候,就开始中原吃鸡大赛了,那不管选哪个都没意义了
上海 30w ,那综合生活成本下来真不如老家公务员,而且还是省会又离家近,如果是县城乡镇公务员那才得考虑考虑
18 天前
回复了 biochen 创建的主题 程序员 Manus 是小甜甜还是牛夫人?
营销大王罢
手机连 wifi 正常吗?还是说用流量才正常?按理说同一片区域的同一运营商 dns 都是相同的
19 天前
回复了 zhoudaiyu 创建的主题 硬件 海光 cpu 性能问题疑问
去找找哪个云提供海光的实例,部署上测试看看
21 天前
回复了 zhangkai1024 创建的主题 生活 高中取消早晚自习老师激动得睡不着
@whp1473 #39 其实就是河南和河北卷,山东资源比其他三个好多了,山西那是招生名额少,教育资源也不好,躺平了
25 天前
回复了 yohane 创建的主题 Apple 心痒痒 m4 macmini,该不该冲动消费?
有闲钱就买,俺买来已经吃灰了(现在放在家里跑 orbstack,jellyfin,当 all in one 用
next.js 在国内流行吗?
41 天前
回复了 StupidMan 创建的主题 生活方式 有丁克的嘛?现在感觉如何?
想清楚了那现在就慢慢过吧,但不要去结扎,给自己留个后路,不要把事情做绝
44 天前
回复了 CKAJ555 创建的主题 问与答 兄弟们 显卡要不要换啊 5090
没必要,就算是原价都感觉没必要,更何况现在黄牛张口就要 5w
收到,这就把椅子撤掉(
我也不希望看到 rust 进入主线内核,但这锅应该 Linus 来背,他的态度模糊导致了其他人的工作白费,虽然 Martin 试图借助媒体闹大给内核维护团队施压也不好;还有就是内核确实该考虑引入一些现代语言了,最起码该划一个 Cpp 的子集,一直坚持 C 那只能让内核维护团队的平均年龄越来越大
52 天前
回复了 haha2333haha 创建的主题 Apple 二手 m1 m2 主板当家用服务器
如果千八百能正常启动,那就无敌了,否则要 2000+那就没意思了
63 天前
回复了 NG6 创建的主题 macOS macOS 的 WindowServer 是真的没的救了吗?
这个问题似乎和特定应用有关,因为我是 3 周没关机占用 2.5g ,感觉也是泄露了但可以接受,不过外接屏幕 100%会快速泄露到不可接受的程度
69 天前
回复了 aqtata 创建的主题 C++ 这种情况如何消除几百个 if/else
@ysc3839 #56 我的,让 chatgpt 生成后感觉差不多就发了,上班摸鱼修改了下:
```
#include <cstdint>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <sstream>
#include <stdexcept>
#include <string>

class BaseClass {
public:
virtual ~BaseClass() = default;
virtual void print() = 0;
};

std::map<uint32_t, BaseClass *> reg;

template <std::uint32_t N> struct myclass : public BaseClass {
void print() override {
throw std::logic_error("Error: myclass<" + std::to_string(N) +
"> is not specialized.");
}
};

template <uint32_t N> void register_classes() {
reg[N] = new myclass<N>();
if constexpr (N > 0) {
register_classes<N - 1>();
}
}

template <> struct myclass<0x1ff> : public BaseClass {
void print() override { std::cout << "Specialized myclass<1f0>\n"; }
};
template <> struct myclass<0x1fa> : public BaseClass {
void print() override { std::cout << "Specialized myclass<2f0>\n"; }
};

// 通用模板函数
void foo(BaseClass *obj) {
obj->print(); // 调用特化模板的成员函数(如果有)
}

// 通用函数:根据运行时输入调用特定模板
void invoke_function(std::string_view hex_input) {
// 将字符串解析为 16 进制数值
std::uint32_t num;
std::stringstream ss;
ss << std::hex << hex_input;
ss >> num;
foo(reg[num]);
}

// 主程序
int main() {
register_classes<0xfff>();

try {
invoke_function("1ff");
invoke_function("1fa");
invoke_function("3f0");
} catch (const std::exception &e) {
std::cerr << "Error: " << e.what() << '\n';
}
for (auto &pair : reg) {
delete pair.second;
}
return 0;
}
```

还是写特化模板就行,编译时给编译器传一个参数:-ftemplate-depth=4096 ;
70 天前
回复了 aqtata 创建的主题 C++ 这种情况如何消除几百个 if/else
用模板就可以解决,

```
#include <iostream>
#include <string>
#include <sstream>
#include <stdexcept>
#include <cstdint>


template<std::uint32_t N>
struct myclass {
void print() const {
throw std::logic_error("Error: myclass<" + std::to_string(N) + "> is not specialized.");
}
};

// 特化模板(如果需要为某些编号提供特定行为)
template<>
struct myclass<0x1f0> {
void print() const { std::cout << "Specialized myclass<1f0>\n"; }
};

template<>
struct myclass<0x2f0> {
void print() const { std::cout << "Specialized myclass<2f0>\n"; }
};

// 通用模板函数
template<std::uint32_t N>
void foo(myclass<N>& obj) {
std::cout << "Called foo<" << std::hex << N << ">\n";
obj.print(); // 调用特化模板的成员函数(如果有)
}

// 通用函数:根据运行时输入调用特定模板
void invoke_function(std::string_view hex_input) {
// 将字符串解析为 16 进制数值
std::uint32_t num;
std::stringstream ss;
ss << std::hex << hex_input;
ss >> num;
myclass<num> obj;
foo(obj);

}

// 主程序
int main() {
try {
invoke_function("1f0"); // 调用 foo<1f0>
invoke_function("2f0"); // 调用 foo<2f0>
invoke_function("3f0"); // 抛出异常
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << '\n';
}
return 0;
}

```

以后要添加新的,直接写个对应的特化模板就完事
1  2  3  4  5  6  7  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1059 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 37ms · UTC 19:00 · PVG 03:00 · LAX 12:00 · JFK 15:00
Developed with CodeLauncher
♥ Do have faith in what you're doing.