By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,122 Members | 1,583 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,122 IT Pros & Developers. It's quick & easy.

"unable to match function definition to an existing declaration"

P: n/a
Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iterator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>::TableType::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
I get the error
line 28 : error C2244: 'MarkerTable<T>::FindErr' : unable to match function
definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T>::FindErr'
definition
'std::vector<T,T2>::iterator MarkerTable<T>::FindErr(unsigned long)'
existing declarations
'vector<Marker<T>>::iterator MarkerTable<T>::FindErr(unsigned long)'

Comeau compiles with no error.
Can you tell me what I'm doing wrong ?

Maett
Sep 10 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

"Maett" <no@spam.pls> wrote in message news:opswv68avtmmfhfz@max...
Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iterator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>::TableType::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
Your code compiles OK for me with VC++ v6.0(SP6).


I get the error
line 28 : error C2244: 'MarkerTable<T>::FindErr' : unable to match
function
definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T>::FindErr'
definition
'std::vector<T,T2>::iterator MarkerTable<T>::FindErr(unsigned
long)'
T2? I don't see that anywhere in your posted code.
Have you made a typo somewhere and the above isn't the real code? :-)

existing declarations
'vector<Marker<T>>::iterator MarkerTable<T>::FindErr(unsigned
long)'

Comeau compiles with no error.
Can you tell me what I'm doing wrong ?


-Mike
Sep 10 '05 #2

P: n/a

"Maett" <no@spam.pls> wrote in message news:opswv68avtmmfhfz@max...
Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iterator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>::TableType::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
I get the error
line 28 : error C2244: 'MarkerTable<T>::FindErr' : unable to match
function
definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T>::FindErr'
definition
'std::vector<T,T2>::iterator MarkerTable<T>::FindErr(unsigned
long)'
existing declarations
'vector<Marker<T>>::iterator MarkerTable<T>::FindErr(unsigned
long)'

Comeau compiles with no error.
Can you tell me what I'm doing wrong ?

Maett


Looks like a compiler bug. VC++ 2005 Beta 2 compiles the code just fine.

Ben
Sep 10 '05 #3

P: n/a
Mike Wahler:

"Maett" <no@spam.pls> wrote in message news:opswv68avtmmfhfz@max...
Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iterator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>::TableType::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
Your code compiles OK for me with VC++ v6.0(SP6).


For me the code also compiled ok with VC++ 6.0 (SP5);
I'm migrating to VC++.NET 2003.


I get the error
line 28 : error C2244: 'MarkerTable<T>::FindErr' : unable to match
function
definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T>::FindErr'
definition
'std::vector<T,T2>::iterator MarkerTable<T>::FindErr(unsigned
long)'
T2? I don't see that anywhere in your posted code.
Have you made a typo somewhere and the above isn't the real code? :-)


Unfortunately it really *is* what VC says.
I don't use T2; no idea where the compiler takes it from.

existing declarations
'vector<Marker<T>>::iterator MarkerTable<T>::FindErr(unsigned
long)'

Comeau compiles with no error.
Can you tell me what I'm doing wrong ?


-Mike


Maett
Sep 10 '05 #4

P: n/a
"Maett" <no@spam.pls> wrote in message news:opswv68avtmmfhfz@max
Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iterator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>::TableType::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
I get the error
line 28 : error C2244: 'MarkerTable<T>::FindErr' : unable to match
function definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T>::FindErr'
definition
'std::vector<T,T2>::iterator MarkerTable<T>::FindErr(unsigned
long)' existing declarations
'vector<Marker<T>>::iterator MarkerTable<T>::FindErr(unsigned
long)'
Comeau compiles with no error.
Can you tell me what I'm doing wrong ?

Maett


Apparently it is a VC++2003 bug. You can work around it by not using the
typedef from MarkerTable when defining FindErr, i.e., make it:

template< class T >
typename std::vector< Marker<T> >::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
}

--
John Carson

Sep 11 '05 #5

P: n/a
John Carson wrote:

Apparently it is a VC++2003 bug. You can work around it by not using the
typedef from MarkerTable when defining FindErr, i.e., make it:

template< class T >
typename std::vector< Marker<T> >::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
}


Great, this works.
Thanks a lot !

Maett
Sep 11 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.