V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  bluearc  ›  全部回复第 4 页 / 共 10 页
回复总数  186
1  2  3  4  5  6  7  8  9  10  
@vcmt 如果真到那时候,就开始中原吃鸡大赛了,那不管选哪个都没意义了
上海 30w ,那综合生活成本下来真不如老家公务员,而且还是省会又离家近,如果是县城乡镇公务员那才得考虑考虑
150 天前
回复了 biochen 创建的主题 程序员 Manus 是小甜甜还是牛夫人?
营销大王罢
手机连 wifi 正常吗?还是说用流量才正常?按理说同一片区域的同一运营商 dns 都是相同的
151 天前
回复了 zhoudaiyu 创建的主题 硬件 海光 cpu 性能问题疑问
去找找哪个云提供海光的实例,部署上测试看看
153 天前
回复了 zhangkai1024 创建的主题 生活 高中取消早晚自习老师激动得睡不着
@whp1473 #39 其实就是河南和河北卷,山东资源比其他三个好多了,山西那是招生名额少,教育资源也不好,躺平了
157 天前
回复了 yohane 创建的主题 Apple 心痒痒 m4 macmini,该不该冲动消费?
有闲钱就买,俺买来已经吃灰了(现在放在家里跑 orbstack,jellyfin,当 all in one 用
next.js 在国内流行吗?
173 天前
回复了 StupidMan 创建的主题 生活方式 有丁克的嘛?现在感觉如何?
想清楚了那现在就慢慢过吧,但不要去结扎,给自己留个后路,不要把事情做绝
176 天前
回复了 CKAJ555 创建的主题 问与答 兄弟们 显卡要不要换啊 5090
没必要,就算是原价都感觉没必要,更何况现在黄牛张口就要 5w
收到,这就把椅子撤掉(
我也不希望看到 rust 进入主线内核,但这锅应该 Linus 来背,他的态度模糊导致了其他人的工作白费,虽然 Martin 试图借助媒体闹大给内核维护团队施压也不好;还有就是内核确实该考虑引入一些现代语言了,最起码该划一个 Cpp 的子集,一直坚持 C 那只能让内核维护团队的平均年龄越来越大
184 天前
回复了 haha2333haha 创建的主题 Apple 二手 m1 m2 主板当家用服务器
如果千八百能正常启动,那就无敌了,否则要 2000+那就没意思了
195 天前
回复了 NG6 创建的主题 macOS macOS 的 WindowServer 是真的没的救了吗?
这个问题似乎和特定应用有关,因为我是 3 周没关机占用 2.5g ,感觉也是泄露了但可以接受,不过外接屏幕 100%会快速泄露到不可接受的程度
201 天前
回复了 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 ;
202 天前
回复了 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;
}

```

以后要添加新的,直接写个对应的特化模板就完事
sg 应该是有针对贫困学生的资助政策,奖学金什么的,可以先贷一年的费用,再确定第二年的费用,尽量减少贷款数额吧,虽然风险比较大,但我觉得是值得去的
210 天前
回复了 Bananana 创建的主题 Apple 各位双持的老哥是怎么携带两台手机的?
我是两个安卓,出门只带常用的小米 15 ,另一个一般就在家里用用
1  2  3  4  5  6  7  8  9  10  
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5826 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 38ms · UTC 03:05 · PVG 11:05 · LAX 20:05 · JFK 23:05
Developed with CodeLauncher
♥ Do have faith in what you're doing.