CppCon 2018: Arthur O'Dwyer “Concepts As She Is Spoke”

preview_player
Показать описание


The last time the keyword `concept` appeared in the C++ Standard's working draft was July 2009, two years before the release of C++11. Now, in September 2018, two years before the expected release of C++20, the working draft once again contains something called "Concepts" — something very different from what was there before, and — so far — much more conservative than the Concepts TS (formerly known as "Concepts Lite").
What should the forward-looking C++ programmer do and know about Concepts in C++2a? Arthur will attempt to puzzle it all out. What is a "Concept" and why should we care? What is the current syntax for defining and using concepts? What compilers support C++2a concepts syntax today, and how do I enable it? How does it affect name-mangling? What are "atomic constraints," "disjunctive clauses," and "subsumption"? What good are value concepts and template concepts? What is the difference between a "requires clause" and a "Requires element"? What is this "terse syntax" we've been hearing about, and why is it controversial? What is "Giraffe_case" and should I use it? Can I use the "requires" keyword without Concepts?
This material will be presented from an outsider's perspective, which means you can expect Arthur to say at least a few wrong things; and the shelf life of this material will be short, as C++2a Concepts are very much in flux right now. Still, if you want to get caught up on (or in) the Concepts discussion, this might be the place for you.

Arthur O'Dwyer

Arthur O'Dwyer started his career writing pre-C++11 compilers for Green Hills Software; he currently writes C++14 for Akamai Technologies. Arthur is the author of "Colossal Cave: The Board Game," "Mastering the C++17 STL" (the book), and "The STL From Scratch" (the training course). He is occasionally active on the C++ Standards Committee and has a blog mostly about C++.


*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

In the http_request example at 8:00, don't we already get a compile time error if the template object doesn't implement body::read/write? And what do we gain from using a concept if the compile error is already being thrown?

loomismeister
Автор

1:00:27 - I think the answer to this question is contracts.

JonathanSharman
Автор

The thing about C++ generic programming is that it is as sophisticated as an undertaking as that of writing a compiler - only a rarified relative few will spend the time to master it's shear complexity - the folks that maintain the template libraries. Rank and file C++ programmers won't typically be able to spend the time to go as deep as necessary to have reasonable competence.

C++ generic programming has probably always been an activity best done by an anointed priesthood while most everyone else just consumes what the priesthood provides. With advent of C++11 and now Concepts in C++20, generic programming has become very much more powerful for that priesthood, but at the same time even more remote from possibility of the rank and file. One could try to dabble in it but there is a just a vast surface area to learn in order to do it well.

This is the thing about the C++ language - it is too complex for rank and file developers to master the full language - they have to settle for a working subset of the language in which they can get their day-to-day work accomplished.

I was enamored with advent of C++11 for a while but am now moving on to Rust to see if is possible for rank and file developers to come close to mastering full capabilities of that language. So far am encouraged as it does much better job of nailing down ownership (move semantics), borrowing (references, slices), mutability control, and lifetimes than Modern C++. I've yet to dive that deeply into its generic programming to see how well that goes, though. And it retains a more sophisticated macro capability that is intended for use. And has some functional ideas - enums and pattern matching are rather interesting.

Modern C++ is excelling with ideas such as constexpr for accomplishing at compile-time what otherwise has usually been computed at runtime - here it is definitely exceeding the thinking in the Rust community as an avenue for garnering more efficiency. And fact that Nividia has targeted C++ memory model with its latest generation GPUs and have adopted and maintain a variant of Modern C++ for programming those GPUs definitely keeps C++ language front and center in that very important arena.

TheSulross
Автор

For all oaf you wheo do talks, keynoteis aned liectures, thouse of you who speaek to an auadience ion generael: Do you knoaw how tirinig it is to listen to soemeone go uuuhm and aah befoire every sentenoce? Makes it imapossible to paey atteantion to anythinyg you say. Doesan't matater how valuabale it is, it's like reading text with random vowels inserted.

GeorgeTsiros