O'Reilly logo

C++ Primer Plus by Stephen Prata

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Template Aliases (C++11)

It can be convenient, especially in template design, to create aliases for types. You can use typedef to create aliases for template specializations:

// define three typedef aliasestypedef std::array<double, 12> arrd;typedef std::array<int, 12> arri;typedef std::array<std::string, 12> arrst;arrd gallons;  // gallons is type std::array<double, 12>arri days;     // days is type std::array<int, 12>arrst months;  // months is type std::array<std::string, 12>

But if you find yourself writing code similar to the preceding typedefs, over and over, you might wonder if you’ve forgotten some language feature that simplifies the task or if the language has forgotten to supply such a feature. In this case, C++11 provides a feature ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required