我已经被困在代码中一段时间了。我可以解决这个问题,但如果我什至无法编译代码,我会感到非常糟糕。代码中描述了这些问题。
namespace fusion = boost::fusion;
template <int N, typename T>
struct viewTraits
{
typedef typename T::value_type value_type;
typedef typename fusion::result_of::as_nview<value_type, N>::type view_type;
typedef std::vector<view_type> result_type;
};
int main ()
{
typedef boost::fusion::vector<int, double> VecType;
typedef std::vector<VecType> Matrix;
typedef viewTraits<0, Matrix>::result_type R;
Matrix m (20);
for (int i = 0; i < 20; ++i)
{
m[i] = VecType (i, i+0.1*i);
}
R r;
/*
* the following can compile, but not what I want
*/
BOOST_FOREACH (Matrix::value_type v, m)
{
r.push_back (fusion::as_nview <0>(v) );
}
/*
* the following cannot compile???, why???
*/
BOOST_FOREACH (Matrix::value_type const &v, m)
{
r.push_back (fusion::as_nview <0>(v) );
}
}
请任何人都可以指出我错过了什么。