دسترسی نامحدود
برای کاربرانی که ثبت نام کرده اند
برای ارتباط با ما می توانید از طریق شماره موبایل زیر از طریق تماس و پیامک با ما در ارتباط باشید
در صورت عدم پاسخ گویی از طریق پیامک با پشتیبان در ارتباط باشید
برای کاربرانی که ثبت نام کرده اند
درصورت عدم همخوانی توضیحات با کتاب
از ساعت 7 صبح تا 10 شب
ویرایش: [Second ed.]
نویسندگان: Björn-Andrist. Viktor-Sehr
سری:
ISBN (شابک) : 1839216549
ناشر:
سال نشر: 2020
تعداد صفحات: [634]
زبان: English
فرمت فایل : PDF (درصورت درخواست کاربر به PDF، EPUB یا AZW3 تبدیل می شود)
حجم فایل: 6 Mb
در صورت تبدیل فایل کتاب Björn-Andrist-Viktor-Sehr-C-High-Performance-Packt-2020 به فرمت های PDF، EPUB، AZW3، MOBI و یا DJVU می توانید به پشتیبان اطلاع دهید تا فایل مورد نظر را تبدیل نمایند.
توجه داشته باشید کتاب Björn-Andrist-Viktor-Sehr-C-High-Performance-Packt-2020 نسخه زبان اصلی می باشد و کتاب ترجمه شده به فارسی نمی باشد. وبسایت اینترنشنال لایبرری ارائه دهنده کتاب های زبان اصلی می باشد و هیچ گونه کتاب ترجمه شده یا نوشته شده به فارسی را ارائه نمی دهد.
Preface Who this book is for What this book covers Get the most out of this book Download the example code files Download the color images Conventions used Get in touch Reviews A Brief Introduction to C++ Why C++? Zero-cost abstractions Programming languages and machine code abstractions Abstractions in other languages The zero-overhead principle Portability Robustness C++ of today C++ compared with other languages Competing languages and performance Non-performance-related C++ language features Value semantics Const correctness Object ownership Deterministic destruction in C++ Avoiding null objects using C++ references Drawbacks of C++ Libraries and compilers used in this book Summary Essential C++ Techniques Automatic type deduction with the auto keyword Using auto in function signatures Forwarding the return type using decltype(auto) Using auto for variables A const reference A mutable reference A forwarding reference Practices for ease of use Const propagation for pointers Move semantics explained Copy-construction, swap, and move Copy-constructing an object Resource acquisition and the rule of five Named variables and rvalues Default move semantics and the rule of zero Rule of zero in a real code base A common pitfall – moving non-resources Applying the && modifier to class member functions Don't move when copies are elided anyway Pass by value when applicable Cases where pass-by-value is not applicable Moving constructor parameters Designing interfaces with error handling Contracts Class invariants Maintaining contracts Error handling Programming error or runtime error? Programming errors (bugs) Recoverable runtime errors Function objects and lambda expressions The basic syntax of a C++ lambda The capture clause Capture by reference versus capture by value Similarities between a lambda and a class Initializing variables in capture Mutating lambda member variables Capture all Assigning C function pointers to lambdas Lambda types Lambdas and std::function Implementing a simple Button class with std::function Performance consideration of std::function Generic lambdas Summary Analyzing and Measuring Performance Asymptotic complexity and big O notation Growth rates Amortized time complexity What to measure and how? Performance properties Speedup of execution time Performance counters Performance testing — best practices Knowing your code and hot spots Instrumentation profilers Sampling profilers Microbenchmarking Amdahl's law Pitfalls of microbenchmarking A microbenchmark example Summary Data Structures The properties of computer memory The standard library containers Sequence containers Vectors and arrays Deque List and forward_list The basic_string Associative containers Ordered sets and maps Unordered sets and maps Container adaptors Priority queues Using views Avoiding copies with string_view Eliminating array decay with std::span Some performance considerations Balancing between complexity guarantees and overhead Knowing and using the appropriate API functions Parallel arrays Summary Algorithms Introducing the standard library algorithms Evolution of the standard library algorithms Solving everyday problems Iterating over a sequence Generating elements Sorting elements Finding elements Finding using binary search Testing for certain conditions Counting elements Minimum, maximum, and clamping Iterators and ranges Introducing iterators Sentinel values and past-the-end iterators Ranges Iterator categories Features of the standard algorithms Algorithms do not change the size of the container Algorithms with output require allocated data Algorithms use operator==() and operator<() by default Custom comparator functions Constrained algorithms use projections Algorithms require move operators not to throw Algorithms have complexity guarantees Algorithms perform just as well as C library function equivalents Writing and using generic algorithms Non-generic algorithms Generic algorithms Data structures that can be used by generic algorithms Best practices Using the constrained algorithms Sorting only for the data you need to retrieve Use cases Performance evaluation Use standard algorithms over raw for-loops Example 1: Readability issues and mutable variables Example 2: Unfortunate exceptions and performance problems Example 3: Exploiting the standard library optimizations Avoiding container copies Summary Ranges and Views The motivation for the Ranges library Limitations of the Algorithm library Understanding views from the Ranges library Views are composable Range views come with range adaptors Views are non-owning ranges with complexity guarantees Views don't mutate the underlying container Views can be materialized into containers Views are lazy evaluated Views in the standard library Range views Generating views Transforming views Sampling views Utility views Revisiting std::string_view and std::span The future of the Ranges library Summary Memory Management Computer memory The virtual address space Memory pages Thrashing Process memory Stack memory Heap memory Objects in memory Creating and deleting objects Placement new The new and delete operators Memory alignment Padding Memory ownership Handling resources implicitly Containers Smart pointers Unique pointer Shared pointer Weak pointer Small object optimization Custom memory management Building an arena A custom memory allocator Using polymorphic memory allocators Implementing a custom memory resource Summary Compile-Time Programming Introduction to template metaprogramming Creating templates Using integers as template parameters Providing specializations of a template How the compiler handles a template function Abbreviated function templates Receiving the type of a variable with decltype Type traits Type trait categories Using type traits Programming with constant expressions Constexpr functions in a runtime context Declaring immediate functions using consteval The if constexpr statement Comparison with runtime polymorphism Example of the generic modulus function using if constexpr Checking programming errors at compile time Using assert to trigger errors at runtime Using static_assert to trigger errors at compile time Constraints and concepts An unconstrained version of a Point2D template Generic interfaces and bad error messages A syntactic overview of constraints and concepts Defining new concepts Constraining types with concepts Function overloading A constrained version of the Point2D template Adding constraints to your code Concepts in the standard library Real-world examples of metaprogramming Example 1: creating a generic safe cast function Example 2: hash strings at compile time The advantages of the compile-time hash sum calculation Implementing and verifying a compile-time hash function Constructing a PrehashedString class Evaluating PrehashedString Evaluating get_bitmap_resource() with PrehashedString Summary Essential Utilities Representing optional values with std::optional Optional return values Optional member variables Avoiding empty states in enums Sorting and comparing std::optional Fixed size heterogenous collections Using std::pair The std::tuple Accessing the members of a tuple Iterating std::tuple members Unrolling the tuple Accessing tuple elements The variadic template parameter pack Dynamically sized heterogenous collections The std::variant Exception safety of std::variant Visiting variants Heterogenous collections using variant Accessing the values in our variant container Global function std::get() Some real-world examples Example 1: projections and comparison operators Example 2: reflection Making a class reflect its members C++ libraries that simplify reflection Using reflection Conditionally overloading global functions Testing reflection capabilities Summary Proxy Objects and Lazy Evaluation Introducing lazy evaluation and proxy objects Lazy versus eager evaluation Proxy objects Avoiding constructing objects using proxy objects Comparing concatenated strings using a proxy Implementing the proxy The rvalue modifier Assigning a concatenated proxy Performance evaluation Postponing sqrt computations A simple two-dimensional vector class The underlying mathematics Implementing the LengthProxy object Comparing lengths with LengthProxy Calculating length with LengthProxy Preventing the misuse of LengthProxy Performance evaluation Creative operator overloading and proxy objects The pipe operator as an extension method The pipe operator Summary Concurrency Understanding the basics of concurrency What makes concurrent programming hard? Concurrency and parallelism Time slicing Shared memory Data races Example: A data race Avoiding data races Mutex Deadlock Synchronous and asynchronous tasks Concurrent programming in C++ The thread support library Threads Thread states Joinable thread Protecting critical sections Avoiding deadlocks Condition variables Returning data and handling errors Tasks Additional synchronization primitives in C++20 Using latches Using barriers Signalling and resource counting using semaphores Atomic support in C++ The lock-free property Atomic flags Atomic wait and notify Using shared_ptr in a multithreaded environment Atomic references The C++ memory model Instruction reordering Atomics and memory orders Lock-free programming Example: A lock-free queue Performance guidelines Avoid contention Avoid blocking operations Number of threads/CPU cores Thread priorities Thread affinity False sharing Summary Coroutines and Lazy Generators A few motivating examples The coroutine abstraction Subroutines and coroutines Executing subroutines and coroutines on the CPU CPU registers, instructions, and the stack Call and return Suspend and resume Stackless versus stackful coroutines Performance cost Memory footprint Context switching What you have learned so far Coroutines in C++ What's included in standard C++ (and what's not)? What makes a C++ function a coroutine? A minimal but complete example The coroutine return object The promise type Awaitable types Passing our coroutine around Allocating the coroutine state Avoiding dangling references Passing parameters to coroutines Member functions that are coroutines Lambdas that are coroutines Guidelines to prevent dangling references Handling errors Customization points Generators Implementing a generator Using the Generator class Solving generator problems An iterator implementation A solution using the Ranges library Conclusion A real-world example using generators The problem Delta encoding Performance Summary Asynchronous Programming with Coroutines Awaitable types revisited The implicit suspend points Implementing a rudimentary task type Handling return values and exceptions Resuming an awaiting coroutine Supporting void tasks Synchronously waiting for a task to complete Implementing sync_wait() Implementing SyncWaitTask Testing asynchronous tasks with sync_wait() Wrapping a callback-based API A concurrent server using Boost.Asio Implementing the server Running and connecting to the server What we have achieved with the server (and what we haven't) Summary Parallel Algorithms The importance of parallelism Parallel algorithms Evaluating parallel algorithms Amdahl's law revisited Implementing parallel std::transform() Naive implementation Divide and conquer Implementing parallel std::count_if() Implementing parallel std::copy_if() Approach 1: Use a synchronized write position Approach 2: Split the algorithm into two parts Performance evaluation Parallel standard library algorithms Execution policies Sequenced policy Parallel policy Unsequenced policy Parallel unsequenced policy Exception handling Additions and changes to parallel algorithms std::accumulate() and std::reduce() std::for_each() Parallelizing an index-based for-loop Combining std::for_each() with std::views::iota() Simplifying construction via a wrapper Executing algorithms on the GPU Summary Other Books You May Enjoy Index