It's a templated function, that part is the declaration of the template types. In the above code, T is used as an alias for the type for the variable "out".
An example of using this function would be:
Because the template type is used as a parameter, the compiler is smart enough to work out that in the above example, T is of type int. If the template type is not used as a parameter, you would have to explicitly specify it (think STL containers).
Strictly speaking the two examples aren't equivalent since std::list is a class, and you always have to specify class template types. The general principal between a templated class and a templated function (or even a templated member function, or even a templated memeber function in a templated class) are all basically the same.
See templates.
An example of using this function would be:
Code:
std::string str = "10";
int val = 0;
if(tryParse(str, val))
{
// val should now be 10
assert(val == 10);
}
Because the template type is used as a parameter, the compiler is smart enough to work out that in the above example, T is of type int. If the template type is not used as a parameter, you would have to explicitly specify it (think STL containers).
Code:
// int is used as the template type of the list
std::list<int> myList;
Strictly speaking the two examples aren't equivalent since std::list is a class, and you always have to specify class template types. The general principal between a templated class and a templated function (or even a templated member function, or even a templated memeber function in a templated class) are all basically the same.
See templates.
The little boat gently drifted across the pond exactly the way a bowling ball wouldn't.