腾讯云
开发者社区
文档
建议反馈
控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
登录/注册
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
(9999+)
视频
沙龙
1
回答
将
boost
variant
与
包含
布尔
输入
的
std
::
函数
一起
使用
c++
、
function
、
pointers
、
boost
、
variant
请参阅以下代码: void stringPtrFunc(const
std
::string *s) {} int main() {
boost
::
variant
<
std
::function<void(const
std
::string *)>,
std
::function<void(const bool)>> myVariant;myVariant = &stringPtrFunc;
浏览 11
提问于2020-05-02
得票数 1
回答已采纳
1
回答
当
std
::可选和
boost
::可选
的
值是变体时
的
区别
c++
、
design-patterns
、
boost-variant
、
state-pattern
、
boost-optional
在嵌入式编程中,内存分配是我们要避免
的
事情。因此,
使用
像状态设计模式这样
的
设计模式是很麻烦
的
。如果我们知道我们会有多少个州,那么我们就可以
使用
新
的
布局操作。但是在这个中,
函数
方法避免了所有内存操作。我尝试在c++11中
使用
boost
::
variant
和
boost
::可选,但是在这个最小
的
中缺少一个转换操作符(这里是用c++17编译
的
,而不是用
std</em
浏览 8
提问于2021-06-22
得票数 1
回答已采纳
1
回答
boost
::
variant
或
std
::
variant
别名不可编译
c++
、
boost
、
c++17
目前我
的
库
使用
boost
::optional和
boost
::
variant
。由于C++17已推出,我想添加一个选项,即它可以
与
boost
和
std
一起
工作。所以我用
boost
optional and
variant
和
std
optional and
variant
成功测试了完整
的
代码。所以我添加了一个类似下面这样
的
头文件: #i
浏览 5
提问于2018-01-21
得票数 1
1
回答
variant
是否提供了类似于
boost
::
variant
<>::types
的
功能?
c++
、
c++17
、
boost-variant
、
boost-mpl
、
std-variant
boost
::
variant
通过
boost
::
variant
<>::types公开了它
的
变体类型列表,可以方便地
与
boost
::mpl::for_each
一起
使用
。
std
::
variant
缺少这样
的
成员。 我看到提供了
std
::
variant
_alternative。这可以用来生成
boost
::mpl::for_ea
浏览 18
提问于2019-09-20
得票数 0
回答已采纳
2
回答
boost
:变体不能同时处理字符串和wstring
c++
、
wstring
、
boost-variant
在试图在库中添加对UTF-8语言环境
的
支持时,我
将
类型
std
::wstring添加到
包含
值
的
boost
::
variant
中。在这一点上,我开始从
boost
::
variant
内部得到一些错误 Blockquote/opt/TWWfsw/libboost147/include/
boost
/
variant
/detail/<em
浏览 8
提问于2013-05-02
得票数 2
1
回答
如何修改
boost
::apply_visitor以返回值?
c++
、
boost-variant
、
apply-visitor
我正在尝试
使用
boost
::
variant
和
boost
::apply_visitor。这已经起作用了,除非我试图使Vistor
函数
返回一个(
布尔
值)值。我看到了很多这样做
的
例子,但我无法创建一个工作样例。这是我
的
代码,没有返回值:#include <
boost
/
variant
.hpp>#inc
浏览 4
提问于2015-11-24
得票数 2
回答已采纳
1
回答
字符串-
布尔
比较-为什么?
c++
、
boost-variant
当我
使用
boost
::
variant
<int,
std
::string,bool>和它
的
访问者时,我遇到了一个意外
的
行为:字符串和
布尔
值是可比较
的
。我不知道为什么它是这样工作
的
,但我发现它很有趣。我唯一
的
想法是,带有
布尔
值
的
变量被解释为char?有人能给我解释一下吗?比较访问者:#include <algorit
浏览 4
提问于2013-01-17
得票数 2
回答已采纳
1
回答
boost
::static_visitor未能对多种可能类型
的
函数
模板进行专门化
c++
、
templates
、
boost
、
operator-overloading
、
sfinae
我正在尝试创建一个访问者
函数
,它将把我
的
boost
::
variant
的
值相加起来。在类型不同
的
情况下,我
使用
模板,例如int + float struct Add : public
boost
::(Add{}, (Values)2, (Values)5.123) <<
std
::endl;
浏览 3
提问于2020-04-29
得票数 2
回答已采纳
4
回答
Boost
变体:如何获取当前持有的类型?
c++
、
boost
、
boost-variant
据我所知,所有类型
的
都被解析成真正
的
类型(这意味着
boost
variant
<int, string> a; a="bla-bla"在编译后会变成string a; a="bla-bla"),所以我想知道:如何
将
什么类型放入
boost
variant
?我尝试了什么:#include <
bo
浏览 3
提问于2011-12-01
得票数 43
2
回答
Boost
二进制static_visitor和apply_visitor
c++
、
templates
、
boost
& water, Visibility vis) const; };SearchParameter param = globeCover.generateSearch(lat, lon, altitude); Visibility,
boost
::tuples::null_type,
boost
浏览 4
提问于2011-05-06
得票数 8
回答已采纳
1
回答
定义
boost
变量类型以显式传递空值
c++
、
boost
、
boost-variant
我想要空状态
的
boost
::
variant
。因此,我定义了一个
boost
::
variant
,
将
boost
::blank作为第一种选择。但是,我想将它作为
函数
参数传递:...{}void g() f(
boost<
浏览 9
提问于2021-12-16
得票数 3
回答已采纳
1
回答
使用
变量变量作为其他变量
函数
的
输入
c++
、
boost-variant
我
使用
了两种不同
的
变体,其中一种可以
包含
比另一种更多
的
类型。typedef
std
::
variant
<
boost
::blank, double> EmptyDouble; typedef
std
::
variant
<
boost
::blank, double, int> EmptyDoubleOrInt; 现在我想
使用
一个以EmptyDoubleOrInt作为参数
的</e
浏览 10
提问于2021-10-28
得票数 0
1
回答
boost
::spirit::karma
使用
带有条件
的
替代运算符(|)
c++
、
boost-spirit
、
boost-variant
、
boost-spirit-karma
我试图
使用
boost
::spirit::karma从我自己
的
类生成一个名为Value
的
字符串,但我遇到了这个问题。我试着把我
的
问题提取到一个简单
的
例子中。我想从以下类
的
实例中生成一个
包含
karma
的
字符串:{ {
boost
::
variant
<boo
浏览 0
提问于2012-09-10
得票数 2
回答已采纳
2
回答
转换
boost
::
variant
类型
的
std
::vector
c++
、
boost
、
c++98
如何实现下面的
函数
将
Value
的
向量转换为Container?我希望断言values
的
所有成员是否都是同一类型
的
,即向量是否
包含
字符串和int
的
混合。这是因为
函数
的
返回值是
std
::vector<int>或
std
::vector<
std
::string>。typedef
boost
::
variant
<int, <em
浏览 0
提问于2013-03-21
得票数 4
回答已采纳
1
回答
boost
::make_recursive_
variant
没有名为“apply_visitor”
的
成员
c++
、
c++11
、
boost
、
boost-variant
第一次
使用
Boost
,并尝试探索如何
使用
boost
::
variant
。Visitable = const
boost
::make_recursive_
variant
<int,
std
::vector<
boost
::recursive_
variant
_,
std
::allocator(visitor);
浏览 2
提问于2016-03-08
得票数 3
回答已采纳
1
回答
转换
boost
::any to
boost
::
variant
的
泛型
函数
c++
、
templates
、
boost
、
boost-variant
、
boost-any
假设您有一个
boost
::any对象和一个
boost
::
variant
对象。我正在寻找一个泛型
函数
convert,它
使用
模板参数T作为一个专门
的
boost
::
variant
,例如
boost
::
variant
<int,
std
::string>,并神奇地
将
boost
::any转换为给定
boost
::
variant
<em
浏览 4
提问于2016-02-12
得票数 3
回答已采纳
0
回答
boost
::
variant
处理仅移动类型中
的
奇怪行为
c++
、
boost
、
c++17
这是在c++17
的
std
::
variant
<>和
boost
::
variant
<>下编译
的
。<B, int> v;} v = B{42}; &
浏览 6
提问于2017-11-27
得票数 3
回答已采纳
2
回答
返回特定类型
的
模板
c++
、
templates
、
return
、
variant
我有一个模板
函数
,我希望返回T类型或变量。我试着这样做,但是编译器报告它不能将'
variant
‘转换成int (我在T=int中
使用
了这个
函数
)。我应该如何实现这一点,以便我可以只返回变量或
包含
在变量中
的
类型。T find_attribute(const
std
::string& attribute, bool isVariant = false)
浏览 0
提问于2011-03-02
得票数 1
回答已采纳
2
回答
将
变体容器解压为容器
的
变体,并结合内部变体类型
c++
、
c++17
、
c++20
一些代码将有助于理解:#include <vector>using ContainerOfMyType =
std
::vector<MyType>; using MySuperType =
std
::
variant
<MyType, Container
浏览 5
提问于2022-03-29
得票数 0
回答已采纳
2
回答
get当前持有的
std
::
variant
类型(类似于
boost
::
variant
type())
c++
、
boost
、
typeid
、
std-variant
我已经从
boost
::
variant
迁移到
std
::
variant
,并遇到了一个问题。如何
使用
std
::变体来实现这一点? 我在'type_index‘上有一个无序
的
map键,它
包含
一些值'
std
::function’。根据类型<em
浏览 1
提问于2018-12-09
得票数 6
回答已采纳
点击加载更多
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
C+17 标准正式发布:开发者可更简单地编写和维护代码
boost:asio中的buffer与streambuf简介
初探Boost.Xpressive正则表达式库
一起学习Boost标准库-Boost.texical
VBA判断函数IsArray、IsDate、IsEmpty、IsEmpty、IsError等
热门
标签
更多标签
云服务器
即时通信 IM
ICP备案
对象存储
实时音视频
活动推荐
运营活动
广告
关闭
领券