c – 使用mpl :: vector定义boost :: variant类型

c – 使用mpl :: vector定义boost :: variant类型,第1张

概述我正在使用库boost :: variant来存储大量类型.随着类型数量的增加,我很快就会达到20种类型的限制.在文档中,似乎可以使用mpl :: vector定义变体,它允许超过20种类型(如果我是正确的话,最多50种).我试图像这样替换我的变体定义: #include <boost/variant.hpp>#include <boost/mpl/vector.hpp>typedef bo 我正在使用库boost :: variant来存储大量类型.随着类型数量的增加,我很快就会达到20种类型的限制.在文档中,似乎可以使用mpl :: vector定义变体,它允许超过20种类型(如果我是正确的话,最多50种).我试图像这样替换我的变体定义:

#include <boost/variant.hpp>#include <boost/mpl/vector.hpp>typedef boost::mpl::vector<    float,math::float2,math::float3,relative_point<1>,relative_point<2>,relative_point<3>,std::string,color,group,dictionnary,reference,line,strip,text,Font> variant_mpl_vec;typedef boost::make_variant_over<variant_mpl_vec>::type data_type;// This is the old deFinition/*typedef boost::variant<    float,Font> data_type;*/

我直接把我的代码.大多数类型都是包含很少数据的结构.

编译时,我有一个奇怪的:

error: no matching function for call to ‘boost::detail::variant::make_initializer_node::apply<boost::mpl::pair< ... and lots more ...

以前的变体定义工作正常,所以我很惊讶我的替换不起作用.我是mpl的新手,所以也许我错过了什么 – 但找不到什么!我做得好吗?

提前致谢.

解决方法 变体类型定义是正确的,问题是由于程序中的泛型函数采用任意变量作为参数.实际上,make_variant_over< mpl :: vector< T0,T1,...>>表现得像变体< T0,...>但不是同一类型:它是变体< over_sequence< vector< T0,...>>> (因此T0对应于over_sequence< vector< T0,...>. 总结

以上是内存溢出为你收集整理的c – 使用mpl :: vector定义boost :: variant类型全部内容,希望文章能够帮你解决c – 使用mpl :: vector定义boost :: variant类型所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1225619.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存