Thirteen Types and a Constant
The basic_string template defines several types that are used later in defining the methods:
typedef traits traits_type; typedef typename traits::char_type value_type; typedef Allocator allocator_type; typedef typename Allocator::size_type size_type; typedef typename Allocator::difference_type difference_type; typedef typename Allocator::reference reference; typedef typename Allocator::const_reference const_reference; typedef typename Allocator::pointer pointer; typedef typename Allocator::const_pointer const_pointer;
Note that traits is a template parameter that will correspond to some specific type, such as char_traits<char>; traits_type will become a typedef for that specific type. The notation
typedef typename ...
Get The Waite Group's C++ Primer Plus, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.