std::vector 和 _variant_t 之间的转换
我需要在 std::vector
和 _variant_t
之间进行转换,以避免在将数据写入/发送数据到某些文件(数据库、Excel 等)时出现循环,
您可以告诉我吗如何进行呢?
我试图获取一个 std::vector<_variant_t> 并以某种方式放入另一个 _variant_t
变量中,但不支持直接转换,即使完成也没有任何一种方法或某种包装器将此向量放入 _variant_t
变量中。
我不想处理任何循环。
I need to convert between std::vector
and _variant_t
to avoid looping when writing/sending data into some file (database, Excel, etc.)
Could you please let me know how to proceed with that?
I was trying to get a std::vector<_variant_t>
and somehow put into another _variant_t
variable, but direct conversion is not supported and even if it's done there's no either method or some kind of wrapper to get this vector into a _variant_t
variable.
I would prefer not to deal with any loops.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
std::vector
和_variant_t
是不兼容的类型。_variant_t
类型旨在支持 COM 接口需要支持相同参数的多种类型值的场景。它的值集仅限于 COM 理解如何封送的值。std::vectory
不是这些类型之一。将值集合存储到
_variant_t
中的标准方法是将其作为安全数组进行存储。因此,最简单的解决方案是将 std::vector 转换为安全数组并将其存储在变体中。这里确实没有办法避免循环A
std::vector
and_variant_t
are incompatible types. The_variant_t
type is designed to support scenarios where a COM interface needs to support multiple types of values for the same parameters. It's set of values is limited to those for which COM understands how to marshal.std::vectory
is not one of those types.The standard way to store a collection of values into a
_variant_t
is to do so as a safe array. So the easiest solution is to convert thestd::vector
to a safe array and store that in the variant. There's really no way to avoid a loop here