P
pvl_google
Hi,
I'm trying to extend an STL class with additional iterator
functionality. In the simplified example below I added an extra
iterator class with a dereferencing operator. This operator
internally relies on the at function of the superclass.
#include <vector>
class LongVector: vector< long >
{
class extraiterator
{
int pos;
long& operator*() { return vector< long >::at( pos ); }
/* other functions removed */
};
};
When I try to compile (with Visual C++ 2005 Express) I get following
ambiguous call error on the at() call, apparently between a const and
a non-const variant of the at() method:
error C2668: 'std::vector<_Ty>::at' : ambiguous call to overloaded
function
1> with
1> [
1> _Ty=long
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include
\vector(728): could be 'long &std::vector<_Ty>::at(unsigned int)'
1> with
1> [
1> _Ty=long
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include
\vector(721): or 'const long &std::vector<_Ty>::at(unsigned int)
const'
1> with
1> [
1> _Ty=long
1> ]
1> while trying to match the argument list '(int)'
I get similar error for any other function I try to use. Anyone an
idea what I'm doing wrong ? Or how I can force the compiler to take a
specific variant ?
Thanks in advance !
I'm trying to extend an STL class with additional iterator
functionality. In the simplified example below I added an extra
iterator class with a dereferencing operator. This operator
internally relies on the at function of the superclass.
#include <vector>
class LongVector: vector< long >
{
class extraiterator
{
int pos;
long& operator*() { return vector< long >::at( pos ); }
/* other functions removed */
};
};
When I try to compile (with Visual C++ 2005 Express) I get following
ambiguous call error on the at() call, apparently between a const and
a non-const variant of the at() method:
error C2668: 'std::vector<_Ty>::at' : ambiguous call to overloaded
function
1> with
1> [
1> _Ty=long
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include
\vector(728): could be 'long &std::vector<_Ty>::at(unsigned int)'
1> with
1> [
1> _Ty=long
1> ]
1> C:\Program Files\Microsoft Visual Studio 8\VC\include
\vector(721): or 'const long &std::vector<_Ty>::at(unsigned int)
const'
1> with
1> [
1> _Ty=long
1> ]
1> while trying to match the argument list '(int)'
I get similar error for any other function I try to use. Anyone an
idea what I'm doing wrong ? Or how I can force the compiler to take a
specific variant ?
Thanks in advance !