Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Back: The mutable Keyword
Forward: Runtime Type Identification (RTTI)
FastBack: Runtime Type Identification (RTTI)
Up: Changeable C++
FastForward: Compiler Quirks
Top: Autoconf, Automake, and Libtool
Contents: Table of Contents
Index: Index
About: About this document

16.2.8 The typename Keyword

The typename keyword was added to C++ after the initial specification and is not recognized by all compilers. It is a hint to the compiler that a name following the keyword is the name of a type. In the usual case, the compiler has sufficient context to know that a symbol is a defined type, as it must have been encountered earlier in the compilation:

class Foo
  typedef int map_t;

func ()
  Foo::map_t m;

Here, map_t is a type defined in class Foo. However, if func happened to be a function template, the class which contains the map_t type may be a template parameter. In this case, the compiler simply needs to be guided by qualifying T::map_t as a type name:

class Foo
  typedef int map_t;

template <typename T>
void func ()
  typename T::map_t t;

This document was generated by Gary V. Vaughan on February, 8 2006 using texi2html

  Published under the terms of the Open Publication License Design by Interspire