User-Defined Types
Definition from C++
Built-in types are ones that can be built from the fundamental types
(e.g. void, std::nullptr_t, int, bool, char, float, double
), the const modifier, and
the declarator operators (e.g. int[3], int*, int&).
While the built-in types directly and efficiently represent the capabilities of conventional computer hardware, they’re too low-level to conveniently write advanced applications in. C++ abstraction mechanisms let programmers design and implement user-defined types using both built-in types and other user-defined types.
User-defined types are often easier to use, less error prone, and typically as efficient as direct use of built-in types.
says that sometimes user-defined types
can be more efficient than built-in types. When would this be? Maybe
something like
std::vector<bool>
,
which is possibly (implementation-defined) more space-efficient than a
std::vector (and thus an array) of bool?
- A Tour of C++ (Second Edition). Chapter 2. User-Defined Types. Bjarne Stroustrup. 2018. ISBN: 978-0-13-499783-4 .
- Fundamental types - cppreference.com. en.cppreference.com . Accessed Jun 4, 2022.
Before this, I thought user-defined types did not include STL types. I thought that user meant me, or library authors, but not the C++ language devs, who, I assume, write the STL.