-
## DEDUCING this PATTERNS

BEN DEANE / @ben_deane
CPPCON 2021
## OVERVIEW
This presentation is about P0847, "Deducing Gašper Ažman, Sy Brand, Ben Deane, Barry Revzin
"We propose a new mechanism for specifying or deducing the value category of the expression that a member-function is invoked on. In other words, a way 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 expressions
0 码力 |
126 页 |
5.15 MB
| 1 年前 3
-
CTAD?
## Deducing function-template template argument
template
void myFunc(const T&){}
myFunc(1); // invokes myFunc specialisation
## Deducing function-template T&){}
myFunc(1); // deduces T = int, invokes myFunc specialisation
## Deducing function-template template argument
template
void myFunc(const T&){}
Template deduction
myFunc(1); // deduces T = int, invokes myFunc specialisation
## Deducing class-template template argument - pre C++17
template
struct myStruct
myStruct(const
0 码力 |
98 页 |
4.62 MB
| 1 年前 3
-
Network Connection
## Derived 1 TCP
## Derived 2 UDP
## Timeline
## V irtual Functions
• ~1986
## Deducing This
• C++23
## Curiously Recurring Template Pattern (CRTP)
• ~1995
## Original Trend – Virtual ed*>
## New Trend – Explicit Object Parameter/Deducing This
C++23 Feature
• Simplifies Compile Time Polymorphism
## New Code – Deducing This
struct NetworkConnection
{
public:
void returned: 0
tcp
tcp
## Multi-Level Inheritance – Deducing This Attempt
// https://godbolt.org/z/ccsoaf3ec
struct NetworkConnection
void init(this auto&&
0 码力 |
60 页 |
1.34 MB
| 1 年前 3
-
d/p27_2.jpg)
Ben Deane
Deducing this Patterns
## The Future of CRTP?

Ben Deane
Deducing this Patterns
## CRTP
Pre /b/2/a/2/b2a240cc83d862dcb67951e72bae578d/p32_2.jpg)
## C++23: Explicit Object Parameter AKA, Deducing This
struct Shape {
template
void draw(this T&& self) { self.draw_impl(); 
## Ben Deane
Deducing this Patterns
## OK, THAT WAS A SIMPLE WIN
There's more. Template deduction is unchanged.
0 码力 |
136 页 |
7.95 MB
| 1 年前 3
-
Feature complete
• C++23
• Deducing this (compiler support)
•
• std::expected
• Many ranges features
Coming next for C++23
• Standard library modules
• Deducing this (modules support) std::print
• Ranges:
• to
• zip and enumerate
• cartesian product
## Coming next for C++23
• Deducing this (modules support)
• 9 remaining C++ STL features
## Announcing
In Visual Studio 2022 version
0 码力 |
55 页 |
3.27 MB
| 1 年前 3
-
CPs Methods

+ @@
Deducing this removes the need for CRTP
## Part II: An Overview Of CPs Methods
• C++ was “born” with Customization >
Inheritance | CTS | CPs (ADL) | CPOs | Concepts (+nominal) | Deducing This | tag_invoke | Custom functions | Reflection | | 0 码力 |
58 页 |
18.82 MB
| 1 年前 3 -
be avoided by delegating to helper methods → Cumbersome
☐ C++23:
☐ Explicit object parameters → deducing this
☐ Replace all 3 overloads with:
template
auto&& GetName(this in 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
| 1 年前 3 -
wait_for( Power::isAwake );
## C++23: Explicit Object Parameter AKA, Deducing This
struct Shape {
template
void draw(this T&& self) { self.draw_impl(); 0 码力 |
43 页 |
536.84 KB
| 1 年前 3 -
>
## PARTIAL APPLICATION, C++ STYLE
(Now you see one of my personal incentives for P0847 Deducing this)
See also C++Weekly Episode 318: My Meetup Got Nerd Sniped!
Tip: attend your local meetup 0 码力 |
141 页 |
11.33 MB
| 1 年前 3 -
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 default 0 码力 |
120 页 |
643.51 KB
| 2 年前 3
|