コンパイラーは(候補としての関数を呼び出すため)私が望むことを実行するのに非常に近いようですが、私は何が間違っているのかわかりません。
#include <stdio.h>
#include <stdlib.h>
#include <list>
using namespace std;
template <class U, template<class U> class T>
void AppendSorted( T<U>& l, U val )
{
typename T<U>::reverse_iterator rt = l.rbegin();
while( ((*rt) > val) && (rt != l.rend()) )
rt++;
l.insert( rt.base(), val );
}
int main( int argc, char* argv[] )
{
list<int> foo;
AppendSorted<int, list<int> >( foo, 5 );
list<int>::iterator i;
for( i = foo.begin(); i != foo.end(); i++ )
{
printf("%d\n",*i);
}
return 0;
}
私が得ているエラーは次のとおりです。
test.cpp: In function ‘int main(int, char**)’:
test.cpp:21:43: error: no matching function for call to ‘AppendSorted(std::list<int>&, int)’
test.cpp:21:43: note: candidate is:
test.cpp:8:6: note: template<class U, template<class U> class T> void AppendSorted(T<U>&, U)