Registered Member
|
I am compiling the following segment of codes to fill a sparsematrix using its reserve() method:
//.... int nSize = 2000, n = 10; SparseMatrix<double> m(nSize ,nSize ); m.reserve(VectorXi::Constant(nSize , n)); //... other codes When compile with Visual Studio 2005 C++, it triggers an error as: "sparsecore\sparsematrix.h(285) : error C2899: typename cannot be used outside a template declaration" However, if I use VS 2010, no compile errors. Is there any way I can get around with this error with VS 2005 (because I still need to use VS 2005 for some reason)? Thanks a lot. |
Moderator
|
This typename is really required though.
Nevertheless, I know that VS permits to not use typename when it is actually required, so could you try to remove it in sparsecore\sparsematrix.h line 285. If it works we can add the workaround upstream. |
Registered Member
|
Thanks for the reply. I have removed typename in sparsecore\sparsematrix.h line 285.as following according to what you have suggested: template<class SizesType> inline void reserve(const SizesType& reserveSizes, const SizesType::Scalar& enableif = SizesType::Scalar()) fro original codes: template<class SizesType> inline void reserve(const SizesType& reserveSizes, const typename SizesType::Scalar& enableif = typename SizesType::Scalar()) After compilation, still got errors: sparsematrix.h(285) : warning C4346: 'SizesType::Scalar' : dependent name is not a type prefix with 'typename' to indicate a type error C2061: syntax error : identifier 'Scalar' error C2143: syntax error : missing ')' before '<end Parse>' Any ideas? |
Registered Member
|
I got the right this way: template<class SizesType> inline void reserve(const SizesType& reserveSizes, const typename SizesType::Scalar& enableif = SizesType::Scalar()) with no compiling errors for vs2005. |
Moderator
|
ok, thank you. I've just applied the workaround.
|
Registered users: Baidu [Spider], Bing [Bot], Google [Bot]