C++23: An Overview of Almost All New and Updated Featuresstd::spanstream std::byteswap() std::to_underlying() Associative Containers Heterogeneous Erasure Removed Features Garbage Collection SupportC++23 Core Language6 Agenda C++23 Core Language std::spanstream std::byteswap() std::to_underlying() Associative Containers Heterogeneous Erasure Removed Features Garbage Collection Support7 Explicit Object Parameters Instead of implicit std::spanstream std::byteswap() std::to_underlying() Associative Containers Heterogeneous Erasure Removed Features Garbage Collection Support13 if consteval Syntax: if consteval { /* A0 码力 | 105 页 | 759.96 KB | 6 月前3
Dependency Injection in C++to inject different functionality • Linking • Inheritance/virtual functions • Templates • Type erasure 29 Bloomberg Dependency Injection BasicsCall any thing satisfying a function signature – via yield; } private : CalculateYield YieldCalculator_; }; 31 Bloomberg Dependency Injection via type erasure Injection Dependency Type Testing Dependency captureTEST(Processor, test_yield) { auto y_calculator processor.process(rdata); EXPECT_EQ(yield.realised, 1); } 32 Bloomberg Dependency Injection via type erasure Injection Dependency Testing VerificationCall any function satisfying a function signature –0 码力 | 106 页 | 1.76 MB | 6 月前3
Relocation: Blazing Fast Save And Restore, Then Morel!contains(id()); } };What about runtime polymorphism? • Programmers make the virtual tables • Zoo type-erasure already generates virtual tables • The handles have the accessor to the virtual table *INDEX* as articulate a new concept: A Value Manager 35Clear & Complete Value Management scenario • In Type Erasure: std::any, especially std::function: • The type of the managed value is “forgotten” at compilation manage a value you don’t know its type • There are different types of value managers (for type erasure): • Local: concerns such as buffer size and alignment • Non-local: • Allocation? • How to0 码力 | 41 页 | 2.81 MB | 6 月前3
C++20 STL Features: 1 Year of Development on GitHubh(skipped_extensions, extension)) { continue; } // ... } } 14Erasing Elements 15Container Erasure Strategies • Erasing unwanted elements before C++20: • vector-like: erase-remove idiom • list-like: Invalidating iterators while looping 🐞 • Skipping elements while looping 🐞 16Uniform Container Erasure • GH-236 and GH-566 implemented by SuperWig #include#include #include return false; } } // ... similarly for _Value > _Ty{_Rx_max} ... return true; } 39Associative Erasure • std::erase_if() is linear time • Inspects the entire value_type • Associative containers have 0 码力 | 45 页 | 989.72 KB | 6 月前3
C++20 STL Features: 1 Year of Development on GitHubextension)) { continue; } // ... } }15 Erasing Elements16 Container Erasure Strategies • Erasing unwanted elements before C++20: • vector-like: erase-remove idiom • list-like: Invalidating iterators while looping 🐞 • Skipping elements while looping 🐞17 Uniform Container Erasure • GH-236 and GH-566 implemented by SuperWig #include#include #include } } // ... similarly for _Value > _Ty{_Rx_max} ... return true; }40 Associative Erasure • std::erase_if() is linear time • Inspects the entire value_type • Associative containers have 0 码力 | 45 页 | 702.09 KB | 6 月前3
Design Patterns: Facts and Misconceptionsstd::forward(f) ) ) {} 83 11. The Type Erasure Design Pattern84 11. The Type Erasure Design Pattern Type Erasure is … … a templated constructor; … a completely non-virtual 0 码力 | 88 页 | 17.31 MB | 6 月前3
Back to Basics: Templates - Part 1to Basics: Templates – Part 1 Copyright © 2021 Bob Steagall 7 The Bad Old Days – Reuse With Type Erasure #includevoid qsort(void *base, size_t nmemb, size_t size, int (*compare)(const void to Basics: Templates – Part 1 Copyright © 2021 Bob Steagall 8 The Bad Old Days – Reuse With Type Erasure + Cut-N-Paste #include #include ... int cmp_str(const void* va, const void* to Basics: Templates – Part 1 Copyright © 2021 Bob Steagall 9 The Bad Old Days – Reuse With Type Erasure + Cut-N-Paste #include #include ... int cmp_str(const void* va, const void* 0 码力 | 68 页 | 436.75 KB | 6 月前3
Breaking Dependencies: The SOLID Principlesmpark::variant 3 9 9 9 9 Strategy 7 2 7 4 2 std::function 8 3 7 7 5 Type Erasure 9 4 8 8 6 1 = very bad, …, 9 = very good Type Erasure 9 4 8 8 6 OO 8 2 2 6 65253 The Open-Closed Principle (OCP) namespace0 码力 | 96 页 | 2.14 MB | 6 月前3
Back to Basics: Algebraic Data Types“union of all copyable types.” ● std::any is a type-erasure type, similar to std::function. ● See my CppCon 2019 talk “Back to Basics: Type Erasure.” Still, I’ll try to mention when there are commonalities0 码力 | 73 页 | 267.05 KB | 6 月前3
Reflection Based Libraries to Look Forward ToImplementing operators 90And there it is! 91It works! 92Now on to member functions 93Need complete type-erasure 94Get member functions with arity 0 95What about higher arity? 96How do we find function signature metaprogramming (Boost.CallableTraits etc) Runtime virtual interface means cannot use template types Type erasure means cannot go from virtual_any to T without RTTI std::any dynamic_cast? Some new ideas? Member0 码力 | 118 页 | 14.33 MB | 6 月前3
共 160 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16













