the line 109 show in asio allocation example
template <typename T>
class handler_allocator
{
...
private:
template <typename> friend class handler_allocator; // line 109
...
}
I wonder what the template < typename > mean ? Is it template < typename T> in commaon way? By the way, the example could work.
handler_allocator
is a class template, as in, only upon concrete instantiation it would result in an actual class. Hence, these instantiations are multiple, so you end up with one class per each T
. In case you want to have these different classes a friend
of each other then this line would be the way to go.
I wonder what the template < typename > mean ? Is it template < typename T> ... ?
Not quite. If you'd add the T
then it would result in invalid code as this T
would shadow the first T
. You could add any other named identifier instead (let's say S
) but it works without it either way as there's no use for it in this snippet.