M
Mark P
I'm having a problem compiling some template code. Here's a seemingly
useless block of code which I've stripped down to illustrate my problem.
Why is the second call to a.foo not accepted by the compiler? Advice
and suggestions are welcomed.
Thanks,
Mark
#include <iterator>
#include <list>
using namespace std;
template <typename T>
struct A
{
template <typename OutIter>
void foo (OutIter& oi);
};
template <typename T>
template <typename OutIter>
void A<T>::foo (OutIter& oi)
{}
int main ()
{
A<int> a;
list<int> output;
// this is fine:
back_insert_iterator<list<int> > bii = back_inserter(output);
a.foo(bii);
// this is not:
a.foo(back_inserter(output));
}
useless block of code which I've stripped down to illustrate my problem.
Why is the second call to a.foo not accepted by the compiler? Advice
and suggestions are welcomed.
Thanks,
Mark
#include <iterator>
#include <list>
using namespace std;
template <typename T>
struct A
{
template <typename OutIter>
void foo (OutIter& oi);
};
template <typename T>
template <typename OutIter>
void A<T>::foo (OutIter& oi)
{}
int main ()
{
A<int> a;
list<int> output;
// this is fine:
back_insert_iterator<list<int> > bii = back_inserter(output);
a.foo(bii);
// this is not:
a.foo(back_inserter(output));
}