V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  ipwx  ›  全部回复第 7 页 / 共 205 页
回复总数  4083
1 ... 3  4  5  6  7  8  9  10  11  12 ... 205  
建议给你的家庭服务器架个 vpn ,你的终端设备连上去
写 dsl 可以用 pyparsing
2024-08-14 17:50:05 +08:00
回复了 happydayandnight 创建的主题 投资 携百万资金,再次梭哈娜娜
@daodao 不知道为啥,国内都把价值投资等价于定投,更有甚者价值投资等于买了装死不动。

也不看看价值投资的巨擘,巴菲特,现在已经清仓了一堆股票了……
2024-08-14 17:03:50 +08:00
回复了 MrLonely 创建的主题 Kubernetes 学不会 k8s 怎么办?
@MrLonely Host 上有个数据目录太正常不过了。

你可以每天跑个定时任务,先关掉 docker compose ,然后把整个数据目录用 tar 打包(以为 tar 可以保存 owner 和权限信息),复制到备份目录,然后再打开 docker compose 。

docker compose down
BACKUP_NAME=$(date +%Y%m%d)
tar czvf ${BACKUP_NAME}.tgz 数据目录名称
rsync -avP ${BACKUP_NAME}.tgz 备份目录/
rm -f ${BACKUP_NAME}.tgz
docker compose up

备份目录可以选择 nas 的硬盘。然后你就可以愉快的使用它,而不用怕数据丢失了。所以我说 docker compose 太好用了。
2024-08-14 10:46:47 +08:00
回复了 HuberyPang 创建的主题 分享创造 两天时间写了个落地页,欢迎大佬点评
大佬,有没有开源的打算,跪求!
2024-08-13 11:32:12 +08:00
回复了 MrLonely 创建的主题 Kubernetes 学不会 k8s 怎么办?
然后,单节点部署我不觉得是麻烦事情。

推荐你学习一下 ansible ,配合 docker ,几十台机器随便你管理。


最后的最后,为啥你都用 docker 了还需要备份虚拟机状态?不是直接 docker compose down ,然后复制一整个 docker compose 目录,最后 docker compose up 就行了嘛?

或者你不知道 docker compose ?
2024-08-13 11:28:24 +08:00
回复了 MrLonely 创建的主题 Kubernetes 学不会 k8s 怎么办?
ummm 作为量化交易员你用这个干嘛。

另外 image 和 container 区别需要很久才能理解,你可能需要让你的学习能力进步一点(
2024-08-13 11:25:43 +08:00
回复了 shimheeyeon 创建的主题 问与答 Web 远程桌面方案求推荐
Linux 的远程桌面体验和 Windows 是比不上的,因为 Windows 内核有支持,RDP 是发送了控件绘制指令,所以很快;但 Linux 虽然 X11 有绘制指令,可乱七八糟的,所以 VNC 基本等于截图。
2024-08-09 14:38:32 +08:00
回复了 Betsy 创建的主题 C++ 求教个 C++ Get 函数怎么写的问题
@lovelylain 你确实 C++ 的细节比我掌握的好,你是个人才。

我只是不推荐楼主去陷入这种不适合工程开发的实践而已。
2024-08-09 12:06:55 +08:00
回复了 Betsy 创建的主题 C++ 求教个 C++ Get 函数怎么写的问题
@lovelylain 简单来说,我反对任何形式地依赖这种语义的写法,原因如下:


const A& a = F();


这句话到底会不会产生一个 BUG ,依赖于 F() 的实现。如果 F() 不符合规范中的情形,你这种写法可能会出错。

对于一个工程而言,如果不能在调用方确定上述用法对不对,那就是个灾难。比如

template <typename F>
void someFunction(F&& f) {
const A& a = F();
...
}

当别人复用你的 someFunction 的时候,它就是个隐藏炸弹。

====


@Betsy 27 楼的问题,人家想做的时候照样能够先把 const T& cast 到 const T* 然后 const cast 。。。

想用是拦不住的。
2024-08-09 12:02:41 +08:00
回复了 Betsy 创建的主题 C++ 求教个 C++ Get 函数怎么写的问题
@lovelylain “ 返回临时对象,用 const&接收返回值,符合 c++标准,没问题的,编译器会处理声明周期。”

嘿你可真是个人才,还真有这个规范:

https://en.cppreference.com/w/cpp/language/reference_initialization

Lifetime of a temporary

Whenever a reference is bound to a temporary or to a subobject thereof, the lifetime of the temporary is extended to match the lifetime of the reference, with the following exceptions:

a temporary bound to a return value of a function in a return statement is not extended: it is destroyed immediately at the end of the return expression. Such function always returns a dangling reference.
a temporary bound to a reference member in a constructor initializer list persists only until the constructor exits, not as long as the object exists. (note: such initialization is ill-formed as of DR 1696).
(until C++14)
a temporary bound to a reference parameter in a function call exists until the end of the full expression containing that function call: if the function returns a reference, which outlives the full expression, it becomes a dangling reference.
a temporary bound to a reference in the initializer used in a new-expression exists until the end of the full expression containing that new-expression, not as long as the initialized object. If the initialized object outlives the full expression, its reference member becomes a dangling reference.
a temporary bound to a reference in a reference element of an aggregate initialized using direct-initialization syntax (parentheses) as opposed to list-initialization syntax (braces) exists until the end of the full expression containing the initializer.

可是这规范又臭又长,而且 "with the following exceptions" 一不留神就用错。为啥不用肯定没问题、而且编译器会负责优化的返回值拷贝呢?
刚刚在隔壁帖子看到一个 OP 270 满融买 TSLA ,现在大概已经亏 60% 了。

我瞬间觉得 OP 其实亏得挺少的。
@hackyuan 260 满融不止损到现在的位置,你让他 230 懂得退出那也太难为 OP 了。
2024-08-08 11:40:59 +08:00
回复了 Betsy 创建的主题 C++ 求教个 C++ Get 函数怎么写的问题
这样,楼主你把 C++ 的引用看成 “指针” 的语法糖就行了。

引用基本就是指针。。。

=====

所以你的第一种,一般可以写成(没有过编译器,手写,不保真):


const Student* Get(const std::string& key) {
auto it = this->map_.find(key);
return (it != this->map_.end()) ? &(it.second) : std::nullptr;
}


然后用的时候

auto myStudent = table.Get("w1");
if (myStudent) {
...
}
2024-08-08 11:38:13 +08:00
回复了 Betsy 创建的主题 C++ 求教个 C++ Get 函数怎么写的问题
额其实第二句也是错的

const Student& stu2 = table.Get("s2");

它只能是

Student stu2 = table.Get("s2");

因为你在类里面

Student Get(const std::string& key) { return this->map_[key]; }

它返回的是 this->map_[key]; 的一个拷贝,而不是 this->map_[key]; 它本身的引用。
====


如果你要写成

const Student& stu2 = table.Get("s2");

你对应的类里面应该写成

const Student& Get(const std::string& key) { return this->map_[key]; }
===

楼主对于 C++ 对象的生存周期是完全不理解啊。。。
2024-08-08 11:35:10 +08:00
回复了 Betsy 创建的主题 C++ 求教个 C++ Get 函数怎么写的问题
楼主上一个帖子里面也出现了类似的写法

const Status& status = table.Get("w1", &stu1);

这句话是错的。你应该

Status status = table.Get("w1", &stu1);

因为你真的返回的是临时对象啊,这句话执行完就没有了啊(
2024-08-07 12:04:45 +08:00
回复了 liuzhiyong 创建的主题 分享创造 多个变量等式计算,实时显示结果(变量计算器)
l=g.eval(e).toString()
2024-08-06 11:26:36 +08:00
回复了 Betsy 创建的主题 C++ 求教个神奇的 C++ 打印问题
optional 类似于


template <typename T>
struct Optional {
T* myObject;

Optional() : myObject(nullptr) {}
Optional(const T& value) : myObject(new T(value)) {}
~Optional() { delete myObject; }

bool has_value() { return myObject != nullptr; }
}
2024-08-06 11:25:15 +08:00
回复了 Betsy 创建的主题 C++ 求教个神奇的 C++ 打印问题
额,楼主你这

std::optional<ReducedGroupId> GetReduceGroupId(const GroupId& group_id) {
// omit
return std::make_optional<ReducedGroupId>(group_id);
}

不是取了 group_id 的地址塞到 optional 里面。optional 本来就是个完整的对象,所以你是复制了一份 group_id 塞到了 optional 里面。

然后

const ReducedGroupId& reduced_group_id

取的就是这个临时的 optional 内部的 int64 的地址,当然这句话执行完就被 “销毁” 了。后面的代码都是错的。
2024-07-31 13:21:49 +08:00
回复了 tho 创建的主题 macOS pdd 的这种显示器是可以购买的吗?“镜面屏 27 寸 4K”
除了分辨率,显示器还有好多纬度

1. 色彩
2. 刷新率
3. 频闪(护眼)

我猜这个价位的 4k 27 寸 都不行。就看你取舍了
1 ... 3  4  5  6  7  8  9  10  11  12 ... 205  
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   3647 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 43ms · UTC 10:22 · PVG 18:22 · LAX 03:22 · JFK 06:22
♥ Do have faith in what you're doing.