I have been stuck in the code for a while. I can work around the issue but feel very bad if I cannot even get the code to compile. The problems were described in the code.
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) );
}
}
Please anyone can point out what I have missed.