V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  bluearc  ›  全部回复第 1 页 / 共 6 页
回复总数  113
1  2  3  4  5  6  
4 小时 32 分钟前
回复了 wniming 创建的主题 Linux 如何看 Hector Martin 退出上游 Linux 内核开发这件事?
我也不希望看到 rust 进入主线内核,但这锅应该 Linus 来背,他的态度模糊导致了其他人的工作白费,虽然 Martin 试图借助媒体闹大给内核维护团队施压也不好;还有就是内核确实该考虑引入一些现代语言了,最起码该划一个 Cpp 的子集,一直坚持 C 那只能让内核维护团队的平均年龄越来越大
5 天前
回复了 haha2333haha 创建的主题 Apple 二手 m1 m2 主板当家用服务器
如果千八百能正常启动,那就无敌了,否则要 2000+那就没意思了
16 天前
回复了 NG6 创建的主题 macOS macOS 的 WindowServer 是真的没的救了吗?
这个问题似乎和特定应用有关,因为我是 3 周没关机占用 2.5g ,感觉也是泄露了但可以接受,不过外接屏幕 100%会快速泄露到不可接受的程度
22 天前
回复了 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 ;
23 天前
回复了 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 应该是有针对贫困学生的资助政策,奖学金什么的,可以先贷一年的费用,再确定第二年的费用,尽量减少贷款数额吧,虽然风险比较大,但我觉得是值得去的
31 天前
回复了 Bananana 创建的主题 Apple 各位双持的老哥是怎么携带两台手机的?
我是两个安卓,出门只带常用的小米 15 ,另一个一般就在家里用用
@xtx window server 似乎有轻微的内存泄露,根据自己的情况定时重启好一点
33 天前
回复了 zhwguest 创建的主题 支付宝 只愿意用微信支付的原因
@bluearc 不过我基本是哪个有优惠用哪个,之前支付宝推广碰一碰,在超市第一次用减了 10 块
33 天前
回复了 zhwguest 创建的主题 支付宝 只愿意用微信支付的原因
@jkfadsljlasdgs #2 相比阿里,我还是更信 tx 点。至于说微信被封后余额不能用,就我身边的情况是被封后支付功能是可以用的,只是社交类功能不能用了,可能是不同情况不一样?
日经贴,就上周同事不知道从哪偷了个 vulkan 相关的 2000 行 Cpp 单体模块,看能不能直接用,测试后显然工作不正常,扔给 deepseek 深度思考,Claude3.5 ,chatgpt o1 ,都可以解决一部分问题,但让它们继续解决剩余未知问题就不行了,综合它们的解决方案也不行,最后还得人肉 debug
如果能量化“正确”,那么排名并不是问题,主要问题在于量化正确,比如说基金看收益,决策问题就复杂了,但可以靠一定范围的人群,限定时间的投票作为分数
没啥问题,我月初在 pdd 买了荣耀 magicpad2 ,比淘宝便宜 200 多,比京东便宜 500 多
国内海关你拆开包装就不会被税,只有一张感觉不拆包装应该也没事,但 5090 能不能过美国海关不好说
自己看的话无所谓,父母还是用 iptv 或者爱优腾吧,我家里是 iptv 还有央视频,加一起 20 块一个月
mac 功耗低,不休眠也行,显示器记得关
play store 上的 nawallet ,忘记中文叫什么了,很好用,没有广告,界面也很简洁,但功能可能没那么全
研究一下退票协议,去程肯定没得商量,回程感觉可以拉扯
60 天前
回复了 arcaitan 创建的主题 问与答 练了俩月电子琴, 决定要入手电钢琴了
前年第一次发年终的时候也买了 fp30x ,现在时不时玩一下,算是半吃灰了
1  2  3  4  5  6  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2733 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 40ms · UTC 14:42 · PVG 22:42 · LAX 06:42 · JFK 09:42
Developed with CodeLauncher
♥ Do have faith in what you're doing.