terryching 最近的时间轴更新
terryching

terryching

V2EX 第 418046 号会员,加入于 2019-06-03 08:55:45 +08:00
terryching 最近回复了
4 天前
回复了 jackie777 创建的主题 分享创造 TabTab v0.3.0 发布 🚀
能不能把浏览器本来的收藏夹一键导入进来,再慢慢调整
@ChristopherWu @nicefrp 迭代的挺快的,比之前好多了
提个建议,最上面的网站名称和“首页”之间是不是分开更好
17 天前
回复了 yytyyf 创建的主题 分享创造 做了一个飞书公开云文档搜索问答工具
飞书上竟然还有这么多公开文档,还以为就公司用用
这 UI 设计,一言难尽
感觉 ASAN 是最适合的
dGVycnlxaW5xdEAxNjMuY29t
2024-02-08 22:02:38 +08:00
回复了 wisefree 创建的主题 C++ C++ 如果通过解析字符串定义一个结构体
看看 GPT4 给出的答案:
运行时解析:使用已有的数据结构,如 std::map 或自定义的数据结构,来在运行时模拟结构体。基于解析得到的信息(字段名、类型、数组大小等),你可以动态地存储和访问数据。这种方法牺牲了类型安全和编译时优化,但提供了灵活性。
```c++
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <typeinfo>
#include <cstdint>

class DynamicStruct {
public:
std::map<std::string, std::vector<uint8_t>> fields;

void addInt(const std::string& name, int value) {
auto data = reinterpret_cast<uint8_t*>(&value);
fields[name] = std::vector<uint8_t>(data, data + sizeof(value));
}

void addDouble(const std::string& name, double value) {
auto data = reinterpret_cast<uint8_t*>(&value);
fields[name] = std::vector<uint8_t>(data, data + sizeof(value));
}

int getInt(const std::string& name) {
if(fields.find(name) != fields.end()) {
auto& data = fields[name];
return *reinterpret_cast<const int*>(data.data());
}
return 0; // Or throw an exception
}

double getDouble(const std::string& name) {
if(fields.find(name) != fields.end()) {
auto& data = fields[name];
return *reinterpret_cast<const double*>(data.data());
}
return 0.0; // Or throw an exception
}

// Similar methods can be added for other types and arrays
};

int main() {
DynamicStruct myStruct;
myStruct.addInt("x", 123);
myStruct.addDouble("y", 456.789);
// For arrays, you might add them element by element or as a block if you know the size

std::cout << "x = " << myStruct.getInt("x") << std::endl;
std::cout << "y = " << myStruct.getDouble("y") << std::endl;

// Accessing array elements would require additional methods

return 0;
}
```
2023-07-21 22:48:12 +08:00
回复了 undertow 创建的主题 程序员 工作一天一般写多少行代码
如果有工作需要一天大部分时间敲代码,有两种可能:1. 复杂度低的重复性代码; 2. 任务分配太多导致工作量大。无论哪种,都可以考虑跑路了
2021-08-20 10:34:27 +08:00
回复了 TOUJOURSER 创建的主题 职场话题 坐在我旁边的同事一直抖腿
直接说就行了,不要想太多
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2585 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 10:20 · PVG 18:20 · LAX 03:20 · JFK 06:20
Developed with CodeLauncher
♥ Do have faith in what you're doing.