I would like to create a generic function that accept as parameters a generic List and a Function(T element), giving out the selected element of the list.
I know how to do this in C# but I'm wondering if there is the same functionality in C++ 10 (because I have to write it in an old program), to avoid to replicate code an infinite amount of times (as already is in the program).
// C# like code
T DisplayList<T>(List<T>& myList, funct<T>(T activeElement))
{
foreach(T element in myList)
{
println(funct(element));
}
T selectedElement = readln();
return selectedElement;
}
// the delegate should be specific "format" function for the T element
delegate string funct<T>(T element);