Skip to main content

Type Synonyms

  • Chapter
  • First Online:
Exploring C++20
  • 1866 Accesses

Abstract

Using types such as std::vector<std::string>::size_type or std::map<std::string, int>::iterator can be clumsy, prone to typographical errors, and just plain annoying to type and read. C++ lets you get away with auto sometimes, but not always. Fortunately, C++ lets you define short synonyms for clumsy types. You can also use type synonyms to provide meaningful names for generic types. (The standard library has quite a few synonyms of the latter variety.) These synonyms are often referred to as typedefs, because you can define them with the typedef keyword, although in modern C++, the using keyword is more common.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 64.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 84.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Ray Lischner

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Lischner, R. (2020). Type Synonyms. In: Exploring C++20. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-5961-0_16

Download citation

Publish with us

Policies and ethics