CppCon 2018: Walter E. Brown “C++ Function Templates: How Do They Really Work?”

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


This talk will focus on C++ function templates and such allied topics as compiler-synthesized function template declarations/signatures, overload resolution and partial ordering of these declarations, and compiler instantiation of function template definitions.

We’ll also look at function template specialization, explaining why to avoid explicit ones, and recommending what to do instead.

Finally, time permitting, we’ll offer advice for customizing function templates in the standard library, especially in light of recent WG21 developments re customization points.

Walter E. Brown
retired
With broad experience in industry, academia, consulting, and research, Dr. Walter E. Brown has been a C++ programmer for over thirty-five years, joining the C++ standards effort in 2000. Among numerous other contributions, he is responsible for introducing such now-standard C++ library features as cbegin/cend, common_type, gcd, and void_t, as well as headers <random> and <ratio>. He has also significantly impacted such core language features as alias templates, contextual conversions, variable templates, and static_assert. He conceived and served as project editor for the International Standard on Mathematical Special Functions in C++, now part of C++17.When not playing with his grandchildren, Dr. Brown is an Emeritus participant in the C++ standards process, with several more core and library proposals under consideration.


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

When I previewed this and saw it was slides with lots of text, I thought "Oh, no, another talk where someone is just going to read slides to us", and expected to move on to something else after about 5 minutes. I'm glad I didn't. If you watch nothing else, watch the sections that cover slides 20 through 22. I've been using C++ since the mid 90s, and I've never seen what he talks about there presented better than he does.

rdwells
Автор

Very clear and informative talk. Thank you.

mwont
Автор

You saved my day trying to understand Explicit Specialisation. Much respect to you!!!

anhkhoa
Автор

49:30 – 51:30 The abbreviated function templates and the constraints – including the adjective syntax – are in C++20. ❤

Bolpat
Автор

44:22 I’m not saying everything about C++ is perfectly named, but STL stands for _standard template library, _ so no surprise there’s a lot of templates in it.

Bolpat
Автор

As usual, yet another very clear presentation from Walter

Radioguy
Автор

Coffee, fruit cake, and a walter brown video. <3

KarelDonk
Автор

An excellent talk! I learned so much from this. Thanks Walter!

jonathanwatmough
Автор

Excellent talk. One question from me, could anyone explain what "name" refer to in "Specialization of a template does not introduce a name"?

kronek
Автор

48:50 It does not seem like std::swap finds another swap in C++20/23, but std::range::swap does. So, use the latter or do the 2-step dance.

Bolpat
Автор

I want to have,
T someFunction (T t) { }
become
std::string someFunction(std::string t) { }
when called with a string literal like
someFunction("somestring")

How would I do that? Type traits? Overloaded proxy w/ explicit cast? What's the idiomatic way?

meepk
Автор

slide 22:
Is it possible to create specialization (b) of (a) after the declaration of (c) or will it always become specialization (d) ?

jjvh
Автор

-- "Function templates are special functions ..."
Conceptually, they can be seen as functions (in a mathematical sense) that take types as arguments and spit out a function (in a C++ sense).

ARTijOMS
Автор

and this is the problem with academic types - function template does not have to be visible in "its entirety", that is why in c++ we have linker, forward declaration /specialization is perfectly acceptable in c++ ( it is not java, the gentleman is probably confused about that )

alexo
Автор

Why the hell do i need to invest space in my brain to hold those rules? Just dont write code in such a way. A code should be cleanly understandable with minimal amount of knowledge and mental work. Inserting artificial rules to solve artificial problems, and expecting people to remember those rules is innefficient.

DanielHsHu