This chapter covered additional IO operations and four library types: tuple
, bitset
, regular expressions, and random numbers.
A tuple
is a template that allows us to bundle together members of disparate types into a single object. Each tuple
contains a specified number of members, but the library imposes no limit on the number of members we can define for a given tuple
type.
A bitset
lets us define collections of bits of a specified size. The size of a bitset
is not constrained to match any of the integral types, and can even exceed them. In addition to supporting the normal bitwise operators (§ 4.8, p. 152), bitset
defines a number of named operations that let us manipulate the state of particular bits in the bitset
.
The regular-expression library provides a collection of classes and functions: The regex
class manages regular expressions written in one of several common regular-expression languages. The match classes hold information about a specific match. These classes are used by the regex_search
and regex_match
functions. These functions take a regex
object and a character sequence and detect whether the regular expression in that regex
matches the given character sequence. The regex
iterator types are iterator adaptors that use regex_search
to iterate through an input sequence and return each matching subsequence. There is also a regex_replace
function that lets us replace the matched part of a given input sequence with a specified alternative.
The random-number library is a collection of random-number engines and distribution classes. A random-number engine returns a sequence of uniformly distributed integral values. The library defines several engines that have different performance characteristics. The default_random_engine
is defined as the engine that should be suitable for most casual uses. The library also defines 20 distribution types. These distribution types use an engine to deliver random numbers of a specified type in a given range that are distributed according to a specified probability distribution.