The STL and the string
Class
The string
class, although not part of the STL, is designed with the STL in mind. For example, it has begin()
, end()
, rbegin()
, and rend()
members. Thus, it can use the STL interface. Listing 16.17 uses the STL to show all the permutations you can form from the letters in a word. A permutation is a rearrangement of the order of the elements in a container. The next_permutation()
algorithm transforms the contents of a range to the next permutation; in the case of a string, the permutations are arranged in ascending alphabetical order. The algorithm returns true
if it succeeds and false
if the range already is in the final sequence. To get all the permutations of a range, you should start with the elements in the earliest ...
Get C++ Primer Plus 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.