bonjour j'ai un petit probleme de template, je souhaite specialiser une fonction template avec un type template

voici un exemple debile mettant en lumiere mon probleme

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 
#include <list>
#include <iostream>
 
template<typename T> T plop(int i)
{
  return T();
}
 
template<> int plop<int>(int i)
{
  return i;
}
 
template<typename T>
std::list<T>
plop<std::list<T> >(int l)
{
  std::list<T> list;
  for (int i =0; i < l; i++)
    {
      list.push_back(plop<T>(i));
    }
  return list;
}
 
 
int main()
{
  std::list<int> l = plop<std::list<int> >(5);
 
  for (std::list<int>::iterator i = l.begin();
       i != l.end(); i++)
      std::cout << *i << std::endl;
}
et le compilo me retourne

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
test.cc:16: error: function template partial specialization ‘plop<std::list<T, std::allocator<_CharT> > >’ is not allowed
test.cc: In function ‘int main()’:
test.cc:30: error: call of overloaded ‘plop(int)’ is ambiguous
test.cc:4: note: candidates are: T plop(int) [with T = std::list<int, std::allocator<int> >]
test.cc:16: note:                 std::list<T, std::allocator<_CharT> > plop(int) [with T = std::list<int, std::allocator<int> >]
Je crois qu'il me dit que mes deux fonctions sont potentiellement acceptable puisqu'il ne voit pas le fait que std::list<T> est deja une specialisation

je ne sais pas comment corriger ca
merci d'avance pour votre aide