Thanks for the reply.
Maybe I was a little ahead of myself then when I said I understood the three uses of the typename keyword in the code snippet I quoted!
I didn't realise the typename keyword could be used like this when calling a constructor.
So now I'm still confused but on a different point. In the only example code for a container in the chapter (Item 53) in the book we see:
1 2 3 4 5 6 7 8
|
template <class T>
class Seq {
public:
typedef T Elem;
typedef T Temp;
size_t size() const;
//...
};
|
and earlier the text reads: "In the process generic algorithm, we need to know the element type (Elem) of Container, as well as a type that could serve to declare a temporary for holding objects of the element type (Temp), but that information is not available until the process function template is instantiated with a specific container."
BTW the "process generic algorithm" is the template function in the code I quoted in my original post on this topic above.
If the suggestion is that Elem and Temp in the example are both typedefs for the same type, why the need for the two typedefs? Also why does the first statement in the template function which I quoted in my original post not simply read:
typename Container::Elem temp;
?