0

I have this typedef in Ogre3D:

namespace Ogre {
    typedef vector<String>::type StringVector;
    ...
}

What is the "::" operator for? Does it do anything? As it is, I think this is a vector of strings - a StringVector. Correct?

Michbeckable
  • 1,851
  • 1
  • 28
  • 41

2 Answers2

1

Defines a type StringVector which is vector<String>::type.

It seems like type is a type, defined inside vector (which is template class)

:: is called "scope resolution operator".

Kiril Kirov
  • 37,467
  • 22
  • 115
  • 187
  • Yes actually now I found this further definition of type: typedef std::vector< T, A > type The Vector is an STL Vector (std::vector) – Michbeckable Feb 20 '13 at 11:57
  • So I see, this is the way needed for a typedef from a template class. Could the identifier "type" be substituted by any identifier like "foo" etc.? – Michbeckable Feb 20 '13 at 12:06
  • @MichiMichbeck - if `foo` is a type, defined in the class/namespace before the scope resolution operator - then yes, `foo` can substitute `type`. – Kiril Kirov Feb 20 '13 at 12:41
0

type is some entity (obviously, a type) declared inside vector class. :: operator is used to reference element type from vector namespace.

P. S. By saying "namespace" I don't only mean the actual C++ namespace feature, since classes are also similar to namespaces in that they can have nested definitions.

Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335