This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Compile error using sparsematrix.reserve method for VS2005

Tags: None
(comma "," separated)
eigenlearner
Registered Member
Posts
17
Karma
0
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.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
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.
eigenlearner
Registered Member
Posts
17
Karma
0
ggael wrote: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.


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?
eigenlearner
Registered Member
Posts
17
Karma
0
ggael wrote: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.


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.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
ok, thank you. I've just applied the workaround.


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot]