gpt4 book ai didi

c++ - 你如何添加两个 boost 任何值?

转载 作者:行者123 更新时间:2023-11-28 08:12:19 25 4
gpt4 key购买 nike

我希望能够添加两个 boost any 值,如下所示:

boost::any lAnyVar = 5;
boost::any lAnyVar2 = 5;
boost::any lSum;

lSum = lAnyVar + lAnyVar2;

and

lAnyVar = lAnyVar + lAnyVar2;

如果 boost 任何类型 ID 不匹配,则可能会抛出异常。

是否存在 boost 或其他能够做到这一点的东西?

最佳答案

Is there something that exists in boost or other to be able to do this?

不是,因为做起来很简单。 boost::any 应该是通用的。对于您需要的东西,它需要为 boost::any 实现 operator+。

关于c++ - 你如何添加两个 boost 任何值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8714602/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com