Skip to Content
C++ Templates: The Complete Guide, 2nd Edition
book

C++ Templates: The Complete Guide, 2nd Edition

by David Vandevoorde, Nicolai M. Josuttis, Douglas Gregor
September 2017
Intermediate to advanced
822 pages
26h 51m
English
Addison-Wesley Professional
Content preview from C++ Templates: The Complete Guide, 2nd Edition

Chapter 5

Tricky Basics

This chapter covers some further basic aspects of templates that are relevant to the practical use of templates: an additional use of the typename keyword, defining member functions and nested classes as templates, template template parameters, zero initialization, and some details about using string literals as arguments for function templates. These aspects can be tricky at times, but every day-to-day programmer should have heard of them.

5.1 Keyword typename

The keyword typename was introduced during the standardization of C++ to clarify that an identifier inside a template is a type. Consider the following example:

template<typename T> class MyClass {   public:          void foo() {

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C++ Software Design

C++ Software Design

Klaus Iglberger

Publisher Resources

ISBN: 9780134778808