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 ...
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.
Read now
Unlock full access