Boost logo

Ublas :

From: Adrien Schvalberg (adrien.schvalberg_at_[hidden])
Date: 2005-08-01 05:36:32


Hi all again,

I have a problem of reference to reference in my code with VC++6
I'm using boost 1.32.0

I try to make the product of a matrix of doubles with a vector of points.
As the +=, + and *(on left with double) operators are defined with my point class,
this should work.

See mvproduct.cpp for example code and vc6_output.txt for compiler error output.

this code works with g++ 3.4.4 but not with VC++6.

in functional.hpp, line 182 there is a hint, but I don't understand how to use it:
         // ISSUE Remove reference to avoid reference to reference problems

does someone has any idea about this phenomenon?

Adrien Schvalberg

PS: I have to use VC6 for my work, so I understand that changing it would be great
(and I'm stuck with many other limitations of VC6), but I can't ;-(


#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>

//just another point class... for example purpose
class FakePoint
{
   friend FakePoint operator+ (const FakePoint&, const FakePoint&);
   friend FakePoint operator* (const double&, const FakePoint&);

private:
   double x;
   double y;

public:
   FakePoint() { FakePoint (0.); }
   FakePoint (double x1) { FakePoint (x1, x1); }
   FakePoint (double x1, double y1) : x(x1), y(y1) {}
   ~FakePoint() {}
   
   void operator+= (const FakePoint& f)
   {
     x += f.x;
     y += f.y;
   }
};

FakePoint operator+ (const FakePoint& f1, const FakePoint& f2)
{
   return FakePoint (f1.x + f2.x, f1.y + f2.y);
}

FakePoint operator* (const double& lambda, const FakePoint& f)
{
   return FakePoint (lambda*f.x, lambda*f.y);
}

int main (char* argc, char** argv)
{
   boost::numeric::ublas::matrix<double> m (5, 5);
   boost::numeric::ublas::vector<FakePoint> v(5);

   //a double matrix times a point vector
   boost::numeric::ublas::vector<FakePoint> toto = boost::numeric::ublas::prod (m, v);
   return 0;
}

main.cpp
D:\Datas\wnccad_dev\boost_1_32_0\boost/numeric/ublas/traits.hpp(36) : warning C4181: qualifier applied to reference type ignored
        D:\Datas\wnccad_dev\boost_1_32_0\boost/numeric/ublas/functional.hpp(183) : see reference to class template instantiation 'boost::numeric::ublas::type_traits<class FakePoint &>' being compiled
        D:\Datas\wnccad_dev\boost_1_32_0\boost/numeric/ublas/functional.hpp(192) : see reference to class template instantiation 'boost::numeric::ublas::scalar_binary_assign_functor<class FakePoint &,double>' being compiled
        D:\Datas\wnccad_dev\boost_1_32_0\boost/numeric/ublas/vector.hpp(83) : see reference to class template instantiation 'boost::numeric::ublas::scalar_assign<class FakePoint &,double>' being compiled
        D:\DATAS\WNCCAD_DEV\COMMONS\splib\main.cpp(103) : see reference to function template instantiation '__thiscall boost::numeric::ublas::vector<class FakePoint,class boost::numeric::ublas::unbounded_array<class FakePoint,class _STL::allocator<c
lass FakePoint> > >::boost::numeric::ublas::vector<class FakePoint,class boost::numeric::ublas::unbounded_array<class FakePoint,class _STL::allocator<class FakePoint> > >(const class boost::numeric::ublas::vector_expression<class boost::numeric::ubl
as::matrix_vector_binary1<class boost::numeric::ublas::matrix<double,struct boost::numeric::ublas::row_major,class boost::numeric::ublas::unbounded_array<double,class _STL::allocator<double> > >,class boost::numeric::ublas::vector<class FakePoint,cl
ass boost::numeric::ublas::unbounded_array<class FakePoint,class _STL::allocator<class FakePoint> > >,struct boost::numeric::ublas::matrix_vector_prod1<double,class FakePoint,double> > > &)' being compiled
D:\Datas\wnccad_dev\boost_1_32_0\boost/numeric/ublas/traits.hpp(36) : error C2529: '<Unknown>' : reference to reference is illegal
        D:\Datas\wnccad_dev\boost_1_32_0\boost/numeric/ublas/functional.hpp(183) : see reference to class template instantiation 'boost::numeric::ublas::type_traits<class FakePoint &>' being compiled
        D:\Datas\wnccad_dev\boost_1_32_0\boost/numeric/ublas/functional.hpp(192) : see reference to class template instantiation 'boost::numeric::ublas::scalar_binary_assign_functor<class FakePoint &,double>' being compiled
        D:\Datas\wnccad_dev\boost_1_32_0\boost/numeric/ublas/vector.hpp(83) : see reference to class template instantiation 'boost::numeric::ublas::scalar_assign<class FakePoint &,double>' being compiled
        D:\DATAS\WNCCAD_DEV\COMMONS\splib\main.cpp(103) : see reference to function template instantiation '__thiscall boost::numeric::ublas::vector<class FakePoint,class boost::numeric::ublas::unbounded_array<class FakePoint,class _STL::allocator<c
lass FakePoint> > >::boost::numeric::ublas::vector<class FakePoint,class boost::numeric::ublas::unbounded_array<class FakePoint,class _STL::allocator<class FakePoint> > >(const class boost::numeric::ublas::vector_expression<class boost::numeric::ubl
as::matrix_vector_binary1<class boost::numeric::ublas::matrix<double,struct boost::numeric::ublas::row_major,class boost::numeric::ublas::unbounded_array<double,class _STL::allocator<double> > >,class boost::numeric::ublas::vector<class FakePoint,cl
ass boost::numeric::ublas::unbounded_array<class FakePoint,class _STL::allocator<class FakePoint> > >,struct boost::numeric::ublas::matrix_vector_prod1<double,class FakePoint,double> > > &)' being compiled
D:\Datas\wnccad_dev\boost_1_32_0\boost/numeric/ublas/traits.hpp(37) : error C2529: '<Unknown>' : reference to reference is illegal
        D:\Datas\wnccad_dev\boost_1_32_0\boost/numeric/ublas/functional.hpp(183) : see reference to class template instantiation 'boost::numeric::ublas::type_traits<class FakePoint &>' being compiled
        D:\Datas\wnccad_dev\boost_1_32_0\boost/numeric/ublas/functional.hpp(192) : see reference to class template instantiation 'boost::numeric::ublas::scalar_binary_assign_functor<class FakePoint &,double>' being compiled
        D:\Datas\wnccad_dev\boost_1_32_0\boost/numeric/ublas/vector.hpp(83) : see reference to class template instantiation 'boost::numeric::ublas::scalar_assign<class FakePoint &,double>' being compiled
        D:\DATAS\WNCCAD_DEV\COMMONS\splib\main.cpp(103) : see reference to function template instantiation '__thiscall boost::numeric::ublas::vector<class FakePoint,class boost::numeric::ublas::unbounded_array<class FakePoint,class _STL::allocator<c
lass FakePoint> > >::boost::numeric::ublas::vector<class FakePoint,class boost::numeric::ublas::unbounded_array<class FakePoint,class _STL::allocator<class FakePoint> > >(const class boost::numeric::ublas::vector_expression<class boost::numeric::ubl
as::matrix_vector_binary1<class boost::numeric::ublas::matrix<double,struct boost::numeric::ublas::row_major,class boost::numeric::ublas::unbounded_array<double,class _STL::allocator<double> > >,class boost::numeric::ublas::vector<class FakePoint,cl
ass boost::numeric::ublas::unbounded_array<class FakePoint,class _STL::allocator<class FakePoint> > >,struct boost::numeric::ublas::matrix_vector_prod1<double,class FakePoint,double> > > &)' being compiled
splib.cpp