~/talk

C++20 Concepts: A Day in the Life

Talkat CppCon 2019 · 2019-09-15..09-20· [c-and-cpp, compilers-and-language-design]
name:Saar Raz
links:none on file
slides:none on file

Shows a concrete C++20 Concepts implementation in Clang implementation and uses it to replace runtime virtual dispatch with compile-time resolution for a component messaging tree, switching vectors to tuples and passing a compile-time context so handlers become constrained templates. Demonstrates abbreviated template syntax and requires expression for clearer errors and safer constructors, then shows the compiled assembly reduced to direct puts calls; cites a reported 30% compile-time speedup for similar use cases.

AI-written summary · about

  1. 0:00Start
  2. 9:08Dynamic Allocation
  3. 23:49Tree Template
  4. 26:15Child Function
  5. 33:51Tree Concept
  6. 37:05Requires Expression
  7. 41:09So We Need To Actually Go Go Back and Try To Refine this Concept and Define It More Accurately so that It Actually Models the Behavior in Case of for Example a Tree with Just One Node in the Root so How Are You GonNa Do that Well One Thing To Go about this Is Actually To Expose a Number of Children from this Let's Say I Need a Static Concepts per Sized Team Child Count and Let It Be the Size of Children Number of Things the Children Has and Here I Can Also for Example Say that I Need There To Be Child Count
  8. 43:36I Have Here I'Ve Also Refined the Context Concept and Defined It in a Similar Way to the Way I Don't See that I'Ve Actually Gone Gone Ahead and Defined the Context Concept in the Similar Way Using Requires Expressions and You Can See that I'Ve Requiring There To Be a Tree for a Context and I'M Required that if You Take that Tree and Take the Type of It and Remove the Reference Then this Should Be a Tree because It Should Be a Reference to a Tree and Also They'Re Required To Be There To Be a Dot Location Which Is a Tree Location Cool Let's Now Try To Write Send-Up Okay the Thing That Sends a Message up the Tree
  9. 44:06And Also They'Re Required To Be There To Be a Dot Location Which Is a Tree Location Cool Let's Now Try To Write Send-Up Okay the Thing That Sends a Message up the Tree First Thing Is Going To Have To Accept as a Message So Let's Write a Message Concept Real Quick Let's Say It's an Object As Well and Here I'M Going To Accept some Sort of Message Cool the First Thing I'M Going To Want To Check Is whether I Am the Route or Not
  10. 49:00What I'M Going To Do It Is Actually Use the Class Template Argument Deduction Just Going To Call this Constructor Here with a the Proper Tree and Location and Let It Deduce the Type of the Context Itself I'M Going To Use the Same Tree in a Location of the Parent Okay and Use Send Up You Actually Store this in a Variable Cool and another Thing We Need Is that Handles Can Actually Receive the Context Itself So if Parent Handle Message and Parent Context Is Valid We Want To Actually Just Let It Have the Context and Not Propagated Ourselves and if another None of these Apply We Just Want To Send the Message Up and Ignore the Parent Cool so this Is Sent Up Let's Write Send Down
  11. 53:11And since We'Ve Checked for Valid Expressions Here Okay We Can Actually Do More Complex Handlers for Example Go to the Idle Component and Let It Handle any Message by Just Writing this Generic Handler Okay So this Handle Now Handles any Message That Passes through It You Can for Example Print Out a Dot Whenever an Idle Receives a Message and another Cool Thing I Can Do Is Write another More Specific Handler That Handles all Messages Whose Size Is More than One and Writes for Example a an Exclamation Mark
  12. 53:27So this Handle Now Handles any Message That Passes through It You Can for Example Print Out a Dot Whenever an Idle Receives a Message and another Cool Thing I Can Do Is Write another More Specific Handler That Handles all Messages Whose Size Is More than One and Writes for Example a an Exclamation Mark and Concepts Will Actually Know Just To Pick the More Specific Handler Here Okay because It Knows that this Function Here Is Defined As Much Constrained as this One It Also Requires a Message but Also Requires More Stuff so It's Actually Going To Pick this Function and Use It To Handle Larger Messages so if We Run this Again We Can See that We Actually Get some Exclamation Points Here Yeah the Dots Are Not Showing Up
  13. 1:04:09And I Think We Are in His New Book Has some Information about that but It's Something the Feature Is Pretty New So I Guess Things Are Going To Build Up as More People Use It Yeah while I'Ve Listed Advantages and Disadvantages of Using this Method of Describing a Concept Based on a Specific Implementation but I Think the Best Way To Go about It Is Just You Know Work with It as You Go Along and like Writing a Good Concept Is Hard and It Requires You To Constantly Expand It That's There Is a Best Practice That Said Use a Standard Concept
  14. 1:05:09But I Think the Best Way To Go about It Is Just You Know Work with It as You Go Along and like Writing a Good Concept Is Hard and It Requires You To Constantly Expand It That's There Is a Best Practice That Said Use a Standard Concept if if There's Exists if There Exists a Standard Concept that Models What She Wants Then Use It except Instead of Writing Your Own but in this in this Example We Didn't Have any so You Have To Somehow Define It and Yeah It's a Gradual Process I Guess
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.