| 回复了 WangLiCha 创建的主题 › 已知两个相交的 polyline 的坐标点集合,怎么求交点的精确坐标?坐标点不在点集里2024 年 3 月 30 日 |
| 回复了 FH0 创建的主题 › 熟悉函数式和 C++ 的老哥有偿帮忙解决个问题2023 年 10 月 30 日 |
```cpp
struct Command
{
std::string msg;
std::string description;
bool require;
std::function<void(std::any)> command;
void exec(std::any v)
{
if (command)
command(v);
}
};
class Args
{
public:
Args *add_opt(Command *command)
{
commandMap[command->msg] = command;
return this;
}
void parse(int argc, char *argv[])
{
// do parse....
std::map<std::string, std::any> valueMap;
for (auto &[key, value] : commandMap) {
if(valueMap.find(key) != valueMap.end()) {
value->exec(valueMap[key]);
} else {
if(value->require) {
// require but not found
}
}
}
}
std::map<std::string, Command *> commandMap;
};
Args *args = new Args();
args->add_opt(
new Command{"-p", "port", true, [](std::any v) { std::cout << std::any_cast<int>(v); }})
->add_opt(new Command())
->add_opt(new Command())
->add_opt(new Command())
->add_opt(new Command());
```
struct Command
{
std::string msg;
std::string description;
bool require;
std::function<void(std::any)> command;
void exec(std::any v)
{
if (command)
command(v);
}
};
class Args
{
public:
Args *add_opt(Command *command)
{
commandMap[command->msg] = command;
return this;
}
void parse(int argc, char *argv[])
{
// do parse....
std::map<std::string, std::any> valueMap;
for (auto &[key, value] : commandMap) {
if(valueMap.find(key) != valueMap.end()) {
value->exec(valueMap[key]);
} else {
if(value->require) {
// require but not found
}
}
}
}
std::map<std::string, Command *> commandMap;
};
Args *args = new Args();
args->add_opt(
new Command{"-p", "port", true, [](std::any v) { std::cout << std::any_cast<int>(v); }})
->add_opt(new Command())
->add_opt(new Command())
->add_opt(new Command())
->add_opt(new Command());
```
| 回复了 FH0 创建的主题 › 熟悉函数式和 C++ 的老哥有偿帮忙解决个问题2023 年 10 月 30 日 |
@FH0 你想要这样只要在 add_option 返回 return this 不就好了
| 回复了 bugmaker1024 创建的主题 › NVIDIA Jetson Linux 35.4.1 安装 qt4 有朋友实践吗?2023 年 10 月 29 日 |
搞过一次 Jetson TX2 Qt5 的: [交叉编译 Qt5 armv8(aarch64) with WebEngine - NVIDIA JETSON TX2]( https://zekexiao.com/cross-build-qt5-aarch64-with-webengine)
| 回复了 chenjia404 创建的主题 › 让自己的博客永存的思路2023 年 7 月 6 日 |
| 回复了 tracker647 创建的主题 › WebServer 异步日志模块, Log 类构析导致线程死锁, 不知如何解除异步线程阻塞2022 年 10 月 11 日 |
@tracker647 应该先 `m_is_async = false;` 再 fclose ,而且应该在置 false 后 join thread 等待线程结束,要不可能会 fputs 到 close 的 handle 里。
| 回复了 sadfQED2 创建的主题 › win11 蛋疼的 bug2022 年 9 月 5 日 |
@cweijan Windows 既然提供了移动这几个目录的功能,为什么不能用
| 回复了 ligiggy 创建的主题 › C++动态内存管理问题求解2022 年 6 月 29 日 |
每组数据就很大了,用之前用 vector.reserve 扩展一下避免分配
| 回复了 Apol1oBelvedere 创建的主题 › 如何下载离线版仅包含 C#和.Net 平台框架的 VisualStudio2022 安装包?2022 年 6 月 6 日 |
| 回复了 microxiaoxiao 创建的主题 › talk is cheap,来观摩一下简单代码2022 年 5 月 27 日 |
suse gcc 12.1/clang14 没有这个问题
| 1/6 |