C++17 STL cookbook over 90 recipes that leverage the powerful features of the standard library in C++17

Over 90 recipes that leverage the powerful features of the Standard Library in C++17 About This Book Learn the latest features of C++ and how to write better code by using the Standard Library (STL). Reduce the development time for your applications. Understand the scope and power of STL features to...

Full description

Bibliographic Details
Other Authors: Galowicz, Jacek, author (author)
Format: eBook
Language:Inglés
Published: Birmingham, [England] : Packt Publishing 2017.
Edition:1st edition
Subjects:
See on Biblioteca Universitat Ramon Llull:https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009630128406719
Table of Contents:
  • Cover
  • Copyright
  • Credits
  • About the Author
  • About the Reviewer
  • www.PacktPub.com
  • Customer Feedback
  • Table of Contents
  • Preface
  • Chapter 1: The New C++17 Features
  • Introduction
  • Using structured bindings to unpack bundled return values
  • How to do it...
  • How it works...
  • There's more...
  • Limiting variable scopes to if and switch statements
  • How to do it...
  • How it works...
  • There's more...
  • Profiting from the new bracket initializer rules
  • How to do it...
  • How it works...
  • Letting the constructor automatically deduce the resulting template class type
  • How to do it...
  • How it works...
  • There's more...
  • Simplifying compile time decisions with constexpr-if
  • How to do it...
  • How it works...
  • There's more...
  • Enabling header-only libraries with inline variables
  • How it's done...
  • How it works...
  • There's more...
  • Implementing handy helper functions with fold expressions
  • How to do it...
  • How it works...
  • There's more...
  • Match ranges against individual items
  • Check if multiple insertions into a set are successful
  • Check if all the parameters are within a certain range
  • Pushing multiple items into a vector
  • Chapter 2: STL Containers
  • Introduction
  • Contiguous storage
  • List storage
  • Search trees
  • Hash tables
  • Container adapters
  • Using the erase-remove idiom on std::vector
  • How to do it...
  • How it works...
  • There's more...
  • Deleting items from an unsorted std::vector in O(1) time
  • How to do it...
  • How it works...
  • Accessing std::vector instances the fast or the safe way
  • How to do it...
  • How it works...
  • There's more...
  • Keeping std::vector instances sorted
  • How to do it...
  • How it works...
  • There's more...
  • Inserting items efficiently and conditionally into std::map
  • How to do it...
  • How it works...
  • There's more.
  • Knowing the new insertion hint semantics of std::map::insert
  • How to do it...
  • How it works...
  • There's more...
  • Efficiently modifying the keys of std::map items
  • How to do it...
  • How it works...
  • There's more...
  • Using std::unordered_map with custom types
  • How to do it...
  • How it works...
  • Filtering duplicates from user input and printing them in alphabetical order with std::set
  • How to do it...
  • How it works...
  • std::istream_iterator
  • std::inserter
  • Putting it together
  • Implementing a simple RPN calculator with std::stack
  • How to do it...
  • How it works...
  • Stack handling
  • Distinguishing operands from operations from user input
  • Selecting and applying the right mathematical operation
  • There's more...
  • Implementing a word frequency counter with std::map
  • How to do it...
  • How it works...
  • Implement a writing style helper tool for finding very long sentences in text with std::multimap
  • How to do it...
  • How it works...
  • There's more...
  • Implementing a personal to-do list using std::priority_queue
  • How to do it...
  • How it works...
  • Chapter 3: Iterators
  • Introduction
  • Iterator categories
  • Input iterator
  • Forward iterator
  • Bidirectional iterator
  • Random access iterator
  • Contiguous iterator
  • Output iterator
  • Mutable iterator
  • Building your own iterable range
  • How to do it...
  • How it works...
  • Making your own iterators compatible with STL iterator categories
  • How to do it...
  • How it works...
  • There's more...
  • Using iterator adapters to fill generic data structures
  • How to do it...
  • How it works...
  • std::back_insert_iterator
  • std::front_insert_iterator
  • std::insert_iterator
  • std::istream_iterator
  • std::ostream_iterator
  • Implementing algorithms in terms of iterators
  • How to do it...
  • There's more.
  • Iterating the other way around using reverse iterator adapters
  • How to do it...
  • How it works...
  • Terminating iterations over ranges with iterator sentinels
  • How to do it...
  • Automatically checking iterator code with checked iterators
  • How to do it...
  • How it works...
  • There's more...
  • Building your own zip iterator adapter
  • How to do it...
  • There's more...
  • Ranges library
  • Chapter 4: Lambda Expressions
  • Introduction
  • Defining functions on the run using lambda expressions
  • How to do it...
  • How it works...
  • Capture list
  • mutable (optional)
  • constexpr (optional)
  • exception attr (optional)
  • return type (optional)
  • Adding polymorphy by wrapping lambdas into std::function
  • How to do it...
  • How it works...
  • Composing functions by concatenation
  • How to do it...
  • How it works...
  • Creating complex predicates with logical conjunction
  • How to do it...
  • There's more...
  • Calling multiple functions with the same input
  • How to do it...
  • How it works...
  • Implementing transform_if using std::accumulate and lambdas
  • How to do it...
  • How it works...
  • Generating cartesian product pairs of any input at compile time
  • How to do it...
  • How it works...
  • Chapter 5: STL Algorithm Basics
  • Introduction
  • Copying items from containers to other containers
  • How to do it...
  • How it works...
  • Sorting containers
  • How to do it...
  • How it works...
  • Removing specific items from containers
  • How to do it...
  • How it works...
  • Transforming the contents of containers
  • How to do it...
  • How it works...
  • Finding items in ordered and unordered vectors
  • How to do it...
  • How it works...
  • Limiting the values of a vector to a specific numeric range with std::clamp
  • How to do it...
  • How it works.
  • Locating patterns in strings with std::search and choosing the optimal implementation
  • How to do it...
  • How it works...
  • Sampling large vectors
  • How to do it...
  • How it works...
  • Generating permutations of input sequences
  • How to do it...
  • How it works...
  • Implementing a dictionary merging tool
  • How to do it...
  • How it works...
  • Chapter 6: Advanced Use of STL Algorithms
  • Introduction
  • Implementing a trie class using STL algorithms
  • How to do it...
  • How it works...
  • Implementing a search input suggestion generator with tries
  • How to do it...
  • How it works...
  • There's more...
  • Implementing the Fourier transform formula with STL numeric algorithms
  • How to do it...
  • How it works...
  • Calculating the error sum of two vectors
  • How to do it...
  • How it works...
  • Implementing an ASCII Mandelbrot renderer
  • How to do it...
  • How it works...
  • Building our own algorithm - split
  • How to do it...
  • How it works...
  • There's more...
  • Composing useful algorithms from standard algorithms - gather
  • How to do it...
  • How it works...
  • Removing consecutive whitespace between words
  • How to do it...
  • How it works...
  • Compressing and decompressing strings
  • How to do it...
  • How it works...
  • There's more...
  • Chapter 7: Strings, Stream Classes, and Regular Expressions
  • Introduction
  • Creating, concatenating, and transforming strings
  • How to do it...
  • How it works...
  • Trimming whitespace from the beginning and end of strings
  • How to do it...
  • How it works...
  • Getting the comfort of std::string without the cost of constructing std::string objects
  • How to do it...
  • How it works...
  • Reading values from user input
  • How to do it...
  • How it works...
  • Counting all words in a file
  • How to do it...
  • How it works...
  • Formatting your output with I/O stream manipulators.
  • How to do it...
  • How it works...
  • Initializing complex objects from file input
  • How to do it...
  • How it works...
  • Filling containers from std::istream iterators
  • How to do it...
  • How it works...
  • Generic printing with std::ostream iterators
  • How to do it...
  • How it works...
  • Redirecting output to files for specific code sections
  • How to do it...
  • How it works...
  • Creating custom string classes by inheriting from std::char_traits
  • How to do it...
  • How it works...
  • Tokenizing input with the regular expression library
  • How to do it...
  • How it works...
  • Comfortably pretty printing numbers differently per context on the fly
  • How to do it...
  • Catching readable exceptions from std::iostream errors
  • How to do it...
  • How it works...
  • Chapter 8 : Utility Classes
  • Introduction
  • Converting between different time units using std::ratio
  • How to do it...
  • How it works...
  • There's more...
  • Converting between absolute and relative times with std::chrono
  • How to do it...
  • How it works...
  • Safely signalizing failure with std::optional
  • How to do it...
  • How it works...
  • Applying functions on tuples
  • How to do it...
  • How it works...
  • Quickly composing data structures with std::tuple
  • How to do it...
  • How it works...
  • operator&lt
  • &lt
  • for tuples
  • The zip function for tuples
  • Replacing void* with std::any for more type safety
  • How to do it...
  • How it works...
  • Storing different types with std::variant
  • How to do it...
  • How it works...
  • Automatically handling resources with std::unique_ptr
  • How to do it...
  • How it works...
  • Automatically handling shared heap memory with std::shared_ptr
  • How to do it...
  • How it works...
  • There's more...
  • Dealing with weak pointers to shared objects
  • How to do it...
  • How it works.
  • Simplifying resource handling of legacy APIs with smart pointers.