Book Image

Learning Boost C++ Libraries

By : Arindam Mukherjee
Book Image

Learning Boost C++ Libraries

By: Arindam Mukherjee

Overview of this book

Table of Contents (19 chapters)
Learning Boost C++ Libraries
About the Author
About the Reviewers

Text processing with Boost String Algorithms library

Text data is commonly represented as a sequence or string of characters laid out contiguously in memory and terminated by a special marker (the null terminator). While the actual data type used to represent a character can vary case by case, the C++ Standard Library abstracts the string concept in the class template std::basic_string, which takes the character data type as a parameter. The std::basic_string template takes three type parameters:

  • The character type

  • Some of the intrinsic properties and behaviors of the character type encapsulated in a traits class

  • An allocator type that is used to allocate the internal data structures for std::basic_string

The traits and allocator parameters are defaulted, as shown in the following snippet:

template <typename charT,
          typename Traits = std::char_traits<chart>,
          typename Allocator = std::allocator<chart>>

The C++03 Standard Library also provides...