DEDUCING this PATTERNS
DEDUCING this PATTERNS BEN DEANE / CPPCON 2021 @ben_deaneOVERVIEW This presentation is about P0847, "Deducing this" ( ) Gašper Ažman, Sy Brand, Ben Deane, Barry Revzin – "We propose a new mechanism mechanism for specifying or deducing the value category of the expression that a member-function is invoked on. In other words, a way to tell from within a member function whether the expression it’s invoked we write) a closure object (the object the compiler generates by evaluating the lambda expression)DEDUCING this AND LAMBDAS First, uniformity of syntax between regular member functions and lambda expressions0 码力 | 126 页 | 5.15 MB | 5 月前3Embracing CTAD
writing your own deduction guides • CTAD take down or CTAD sales pitch • PopcornWhat is CTAD ?Deducing function-template template argument templatevoid myFunc(const T&){} myFunc(const T&){} myFunc(1); // deduces T = int, invokes myFunc specialisation Deducing function-template template argumenttemplate void myFunc(const T&){} myFunc(1); myFunc(1); // deduces T = int, invokes myFunc specialisation Template argument deduction Deducing function-template template argumenttemplate struct myStruct { myStruct(const 0 码力 | 98 页 | 4.62 MB | 5 月前3Newer Isn't Always Better
UDPatomosspace.com | 47 Virtual Functions • ~1986 Curiously Recurring Template Pattern (CRTP) • ~1995 Deducing This • C++23 Timelineatomosspace.com | 48 • Run-Time Polymorphism • Quintessential Object Oriented • C++23 Feature • Simplifies Compile Time Polymorphism New Trend – Explicit Object Parameter/Deducing Thisatomosspace.com | 53 struct NetworkConnection { public: void init(this auto&& self) NetworkConnection { public: void initializeConfig() { // ... } }; New Code – Deducing Thisatomosspace.com | 54 // https://godbolt.org/z/T51xE5qbK struct NetworkConnection { virtual0 码力 | 60 页 | 1.34 MB | 5 月前3C++23: An Overview of Almost All New and Updated Features
avoided by delegating to helper methods Cumbersome C++23: Explicit object parameters deducing this Replace all 3 overloads with: templateauto&& GetName(this Self&& self) a lambda accesses the object that contains the lambda, not the lambda instance itself! With deducing this: auto fibonacci = [](this auto self, int n) { if (n < 2) { return n; } return self(n 0 码力 | 105 页 | 759.96 KB | 5 月前3Applicative: The Forgotten Functional Pattern
one of my personal incentives for P0847 (Now you see one of my personal incentives for P0847 Deducing Deducing this this)) See also See also C++Weekly Episode 318: My Meetup Got Nerd Sniped! C++Weekly0 码力 | 141 页 | 11.33 MB | 5 月前3Connecting User And Library Code
without frame is in UserSpace@@@ As opposed to library sharing entities with other libraries+ @@@ Deducing this removes the need for CRTP2 Slides1. https://godbolt.org/z/eTznPrno5 @@@ Use default if there’s0 码力 | 58 页 | 18.82 MB | 5 月前3A Journey Into Non-Virtual Polymorphism
Rud Merriam | A Journey into Non-Virtual Polymorphism 41 C++23: Explicit Object Parameter AKA, Deducing This struct Shape { templatevoid draw(this T&& self) { self.draw_impl();} 0 码力 | 43 页 | 536.84 KB | 5 月前3What's New in Visual Studio 2022
std::print • Ranges: • to • zip and enumerate • cartesian_product 🕙 Coming next for C++23 • Deducing this (modules support) • 9 remaining C++ STL features ✅ C++98* * with /permissive- ✅ C++11 ✅0 码力 | 55 页 | 3.27 MB | 5 月前3Design Patterns
getValue() = {}", s.getValue() ); } No template parameter anymore 😊 Explicit object parameter (aka “Deducing This”)The Future of CRTP? 31 So CRTP really just … I guess … goes away.The Future of CRTP? 32The0 码力 | 136 页 | 7.95 MB | 5 月前3Debian GNU/Linux 安裝手冊 January 8, 2024
with the same key always produces a unique cipher text. The idea is to prevent the attacker from deducing information from repeated patterns in the encrypted data. From the provided alternatives, the default0 码力 | 120 页 | 643.51 KB | 1 年前3
共 163 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17