0

what is this concept called as:

typename T::size_type Length

I am not able to understand what's going in this line. Can somebody help me with this.

NixiN
  • 83
  • 9
  • 1
    [Where and why do I have to put the “template” and “typename” keywords?](http://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords) – Some programmer dude Jun 16 '15 at 12:00
  • http://en.cppreference.com/w/cpp/language/dependent_name – 101010 Jun 16 '15 at 12:00
  • can u please help me with the line of code i have posted coz i am not getting it – NixiN Jun 16 '15 at 12:03
  • In a declaration or a definition of a template, including alias template, a name that is not a member of the current instantiation and is dependent on a template parameter is not considered to be a type unless the keyword typename is used or unless it was already established as a type name, e.g. with a typedef declaration or by being used to name a base class. – 101010 Jun 16 '15 at 12:05

1 Answers1

3

By adding typename before T::size_type, C++ will treat size_type as a type, rather than a static member in T. This is required when you use type members of a template parameter.

Therefore, this line just defines a variable Length with type T::size_type.

delphifirst
  • 1,781
  • 1
  • 14
  • 23