typename is needed in your declaration of 'it' because otherwise the compiler doesn't know that it's a type declaration rather than an expression.
According to this page, "Use the keyword typename if you have a qualified name that refers to a type and depends on a template parameter."