M
Matthias Pfeifer
Hi there,
I am trying to declare a function that takes a std::list<> parameter.
I want this function to have an empty list as a default parameter.
It's a template function also. Currently i am stuck because my
compiler does not find a matching function when i do a call.
here is my code:
// ############## code begins
#include <list>
using namespace std;
template<typename T>
int* f(const int*,
const int*,
const int*,
list<pair<int, T > > =list<pair<int, int > >() );
int main (int argc, char* argv)
{
int* c, t, i;
int* result = f(c, t, i);
}
template<typename T>
int* f(const int* c, const int* t, const int* i,
list<pair<int, T > > )
{
return (int *) 0;
}
// ############## code ends
compiler says
testcase.cpp: In function 'int main(int, char*)':
testcase.cpp:16: error: no matching function for call to 'f(int*&, int&,
int&)'
compiler version is g++ 4.0.2. I guess i am doing wrong with the syntax
here. Would be nice if someone knows how to do this right... thanks in
advance.
matthias
I am trying to declare a function that takes a std::list<> parameter.
I want this function to have an empty list as a default parameter.
It's a template function also. Currently i am stuck because my
compiler does not find a matching function when i do a call.
here is my code:
// ############## code begins
#include <list>
using namespace std;
template<typename T>
int* f(const int*,
const int*,
const int*,
list<pair<int, T > > =list<pair<int, int > >() );
int main (int argc, char* argv)
{
int* c, t, i;
int* result = f(c, t, i);
}
template<typename T>
int* f(const int* c, const int* t, const int* i,
list<pair<int, T > > )
{
return (int *) 0;
}
// ############## code ends
compiler says
testcase.cpp: In function 'int main(int, char*)':
testcase.cpp:16: error: no matching function for call to 'f(int*&, int&,
int&)'
compiler version is g++ 4.0.2. I guess i am doing wrong with the syntax
here. Would be nice if someone knows how to do this right... thanks in
advance.
matthias