售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Title Page
Copyright
C++17 STL Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Compiling and running the recipes
Requirements for early adopters
Who this book is for
Sections
Getting ready
How to do it…
How it works…
There's more…
See also
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
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
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...
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
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...
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...
Advanced Use of STL Algorithms
Introduction
Implementing a trie class using STL algorithms
How to do it...
How it works...
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...
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...
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<< 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
How to do it...
How it works...
Sharing different member values of the same object
How to do it...
How it works...
Generating random numbers and choosing the right random number engine
How to do it...
How it works...
Generating random numbers and letting the STL shape specific distributions
How to do it...
How it works...
Parallelism and Concurrency
Introduction
Automatically parallelizing code that uses standard algorithms
How to do it...
How it works...
Which STL algorithms can we parallelize this way?
How do those execution policies work?
What does vectorization mean?
Putting a program to sleep for specific amounts of time
How to do it...
How it works...
Starting and stopping threads
How to do it...
How it works...
Performing exception safe shared locking with std::unique_lock and std::shared_lock
How to do it...
How it works...
Mutex classes
Lock classes
Avoiding deadlocks with std::scoped_lock
How to do it...
How it works...
Synchronizing concurrent std::cout use
How to do it...
How it works...
Safely postponing initialization with std::call_once
How to do it...
How it works...
Pushing the execution of tasks into the background using std::async
How to do it...
How it works...
There's more...
Implementing the producer/consumer idiom with std::condition_variable
How to do it...
How it works...
Implementing the multiple producers/consumers idiom with std::condition_variable
How to do it...
How it works...
Parallelizing the ASCII Mandelbrot renderer using std::async
How to do it...
How it works...
Implementing a tiny automatic parallelization library with std::future
How to do it...
How it works...
Filesystem
Introduction
Implementing a path normalizer
How to do it...
How it works...
There's more...
Getting canonical file paths from relative paths
How to do it...
How it works...
Listing all files in directories
How to do it...
How it works...
Implementing a grep-like text search tool
How to do it...
How it works...
There's more...
Implementing an automatic file renamer
How to do it...
Implementing a disk usage counter
How to do it...
How it works...
Calculating statistics about file types
How to do it...
Implementing a tool that reduces folder size by substituting duplicates with symlinks
How to do it...
How it works...
There's more...
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜