fork(1) download
  1. #include <list>
  2. #include <algorithm>
  3.  
  4. template<class Vertex, class Edge>
  5. class Graph
  6. {
  7. public:
  8. typedef int VertexID;
  9. };
  10.  
  11. template<template<typename> class List, typename T>
  12. bool isInList(List<T> const& l, T x)
  13. {
  14. return std::find(std::begin(l), std::end(l), x) != std::end(l);
  15. }
  16.  
  17. template<class Vertex, class Edge>
  18. void fuuuuu(Graph<Vertex, Edge> const& g)
  19. {
  20. typedef Graph<Vertex, Edge> MyGraph;
  21. typedef typename MyGraph::VertexID Node;
  22. typedef std::list<Node> List;
  23.  
  24. List l;
  25. Node id;
  26.  
  27. if ( isInList(l, id) )
  28. return;
  29. }
  30.  
  31. int main()
  32. {
  33. Graph<double, float> g;
  34.  
  35. fuuuuu(g);
  36.  
  37. return 0;
  38. }
  39.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘void fuuuuu(const Graph<Vertex, Edge>&) [with Vertex = double; Edge = float]’:
prog.cpp:35:10:   required from here
prog.cpp:27:21: error: no matching function for call to ‘isInList(List&, Node&)’
  if ( isInList(l, id) )
                     ^
prog.cpp:27:21: note: candidate is:
prog.cpp:12:6: note: template<template<class> class List, class T> bool isInList(const List<T>&, T)
 bool isInList(List<T> const& l, T x)
      ^
prog.cpp:12:6: note:   template argument deduction/substitution failed:
prog.cpp:27:21: error: wrong number of template arguments (2, should be 1)
  if ( isInList(l, id) )
                     ^
prog.cpp:11:35: error: provided for ‘template<class> class List’
 template<template<typename> class List, typename T>
                                   ^
stdout
Standard output is empty