升压融合:视元素数量上的向量奇怪的问题 [英] boost fusion: strange problem depending on number of elements on a vector

查看:117
本文介绍了升压融合:视元素数量上的向量奇怪的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在个人项目中使用的boost ::融合(升压v1.42.0)。我得到一个有趣的错误与此code:

I am trying to use Boost::Fusion (Boost v1.42.0) in a personal project. I get an interesting error with this code:

#include "boost/fusion/include/sequence.hpp"
#include "boost/fusion/include/make_vector.hpp"
#include "boost/fusion/include/insert.hpp"
#include "boost/fusion/include/invoke_procedure.hpp"
#include "boost/fusion/include/make_vector.hpp"
#include <iostream>

class Class1
{ 
    public:
    typedef boost::fusion::vector<int,float,float,char,int,int> SequenceType;
    SequenceType s;
        Class1(SequenceType v):s(v){}
};

class Class2
{
    public:
    Class2(){}
    void met(int a,float b ,float c ,char d ,int e,int f)
    {
        std::cout << a << " " << b << " " << c << " " << d << " " << e << std::endl;
    }
};

int main(int argn, char**)
{
Class2 p;
Class1 t(boost::fusion::make_vector(9,7.66f,8.99f,'s',7,6));
boost::fusion::begin(t.s); //OK
boost::fusion::insert(t.s, boost::fusion::begin(t.s), &p); //OK
boost::fusion::invoke_procedure(&Class2::met,boost::fusion::insert(t.s, boost::fusion::begin(t.s), &p)); //FAILS
}

它未能编译(GCC 4.4.1):

It fails to compile (gcc 4.4.1):

In file included from /home/thechaos/Escriptori/of_preRelease_v0061_linux_FAT/addons/ofxTableGestures/ext/boost/fusion/include/invoke_procedur
e.hpp:10,
                 from problema concepte.cpp:11:
/home/thechaos/Escriptori/of_preRelease_v0061_linux_FAT/addons/ofxTableGestures/ext/boost/fusion/functional/invocation/invoke_procedure.hpp: I
n function ‘void boost::fusion::invoke_procedure(Function, const Sequence&) [with Function = void (Class2::*)(int, float, float, char, int, in
t), Sequence = boost::fusion::joint_view<boost::fusion::joint_view<boost::fusion::iterator_range<boost::fusion::vector_iterator<const boost::f
usion::vector<int, float, float, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_>, 0>, 
boost::fusion::vector_iterator<boost::fusion::vector<int, float, float, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fus
ion::void_, boost::fusion::void_>, 0> >, const boost::fusion::single_view<Class2*> >, boost::fusion::iterator_range<boost::fusion::vector_iter
ator<boost::fusion::vector<int, float, float, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion:
:void_>, 0>, boost::fusion::vector_iterator<const boost::fusion::vector<int, float, float, char, int, int, boost::fusion::void_, boost::fusion
::void_, boost::fusion::void_, boost::fusion::void_>, 6> > >]’:
problema concepte.cpp:39:   instantiated from here
/home/thechaos/Escriptori/of_preRelease_v0061_linux_FAT/addons/ofxTableGestures/ext/boost/fusion/functional/invocation/invoke_procedure.hpp:88
: error: incomplete type ‘boost::fusion::detail::invoke_procedure_impl<void (Class2::*)(int, float, float, char, int, int), const boost::fusio
n::joint_view<boost::fusion::joint_view<boost::fusion::iterator_range<boost::fusion::vector_iterator<const boost::fusion::vector<int, float, f
loat, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_>, 0>, boost::fusion::vector_itera
tor<boost::fusion::vector<int, float, float, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::
void_>, 0> >, const boost::fusion::single_view<Class2*> >, boost::fusion::iterator_range<boost::fusion::vector_iterator<boost::fusion::vector<
int, float, float, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_>, 0>, boost::fusion:
:vector_iterator<const boost::fusion::vector<int, float, float, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fusion::voi
d_, boost::fusion::void_>, 6> > >, 7, true, false>’ used in nested name specifier

但是,如果我更改的参数在向量的数量,并从6到5从整型,浮点,浮点型,字符型,INT,INT 的方法整型,浮点,浮点型,字符型,INT ,我可以编译它没有问题。

However, if I change the number of arguments in the vectors and the method from 6 to 5 from int,float,float,char,int,int to int,float,float,char,int,I can compile it without problems.

我怀疑有关的参数是一个限制的最大数量,但我​​试图通过定义 FUSION_MAX_VECTOR_SIZE 没有成功改变它。

I suspected about the maximum number of arguments being a limitation, but I tried to change it through defining FUSION_MAX_VECTOR_SIZE without success.

我看不到我在做什么错。你能重现吗?它可以是一个提升的bug(我对此表示怀疑,但也不是不可能的)?

I am unable to see what am I doing wrong. Can you reproduce this? Can it be a boost bug (i doubt it but is not impossible)?

推荐答案

的确不错,您需要更改一些迭代限制。你只是改变了错误的。 :)

Yes indeed, you need to change some iteration limits. You're just changing the wrong one. :)

您需要定义什么是 BOOST_FUSION_INVOKE_PROCEDURE_MAX_ARITY ;默认情况下,它是6。你显然需要7(但还不如它颠簸10个):

What you need to define is BOOST_FUSION_INVOKE_PROCEDURE_MAX_ARITY; by default, it is 6. You obviously need 7 (but might as well bump it to 10):

#define BOOST_FUSION_INVOKE_PROCEDURE_MAX_ARITY 10

#include "boost/fusion/include/sequence.hpp"
#include "boost/fusion/include/make_vector.hpp"
#include "boost/fusion/include/insert.hpp"
#include "boost/fusion/include/invoke_procedure.hpp"
#include "boost/fusion/include/make_vector.hpp"
#include <iostream>
.
.
.

有<一个href=\"http://www.boost.org/doc/libs/1_42_0/libs/fusion/doc/html/fusion/functional/invocation/limits.html\"相对=nofollow>调用域内总共三个。

当你正在寻找的东西的限制,寻找对的文档。选择相关的你在做什么的人。从那里,它会告诉你的默认值,什么选择。

Whenever you're looking for the limit of something, search for "Limits" on the documentation. Choose the one relevant to what you're doing. From there, it tells you the defaults and what the options are.

就有关code本身,我要指出的是有<一个href=\"http://www.boost.org/doc/libs/1_42_0/libs/fusion/doc/html/fusion/algorithm/transformation/functions.html\"相对=nofollow> push_front 功能:

Just concerning the code itself, I should point out there is a push_front function:

#include "boost/fusion/include/push_front.hpp"

// ...

boost::fusion::invoke_procedure(&Class2::met,
                                boost::fusion::push_front(t.s, &p));

所以,你不需要做更详细的插入-AT-开始。

So you don't need to do the more verbose insert-at-begin.

这篇关于升压融合:视元素数量上的向量奇怪的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆