No video

An Adventure in Modern C++ Library Design - Robert Leahy - C++Now 2024

  Рет қаралды 3,876

CppNow

CppNow

Күн бұрын

Пікірлер: 4
@spyofgame200
@spyofgame200 Ай бұрын
Wow, I watched for an hour and just realized it was released on KZfaq only an hour ago.
@SamWhitlock
@SamWhitlock 19 күн бұрын
36:10 can someone enlighten me about the `void run();` use here? I'm trying to understand what value that adds for the function name lookup
@robertleahy6923
@robertleahy6923 14 күн бұрын
Speaker here. When you perform qualified name lookup, for example by typing std::swap in your code, you will call a matching overload of swap which is found in exactly the given scope (in this case std). When you perform unqualified name lookup, for example by typing just swap in your code, the search for matching overloads is more interesting. First "regular unqualified name lookup" is performed, which searches for a matching name by looking in enclosing scopes until a match is found. So, for example, if you type quux(a) in a function in the namespace foo::bar regular unqualified name lookup will search: 1. The function body itself, then if no name quux is found 2. The namespace foo::bar, then if no name quux is found 3. The namespace foo, and then if no name quux is found 4. The global namespace Note the "then if no name quux is found." If a name quux is found the search stops immediately. So if you have a quux in foo::bar and in foo only foo::bar::quux will be found, foo::quux will not be considered. Once regular unqualified name lookup finds a match, if the match is a regular function, then another kind of lookup continues populating the "candidate set" (the set of overloads with the correct name which are found by name lookup): Argument dependent lookup. This lookup tries to find matches in the "associated namespaces" of arguments to the function call. So in this case the namespaces containing: - The type of a, and - The template arguments used to instantiate the type of a, if any Are the associated namespaces. All names quux from those namespaces are then added to the candidate set, and then overload resolution occurs. In the example you're talking about we don't want any alternatives which are put in the candidate set by regular unqualified name lookup, we only want names from argument dependent lookup, which means we need to inhibit regular unqualified name lookup somehow. The way we do this is add a "poison pill:" The declaration of a function run (without a definition). Within detail::run when regular unqualified name lookup starts searching for a match it will first consider the calling context, and then detail::run. Once it searches inside detail::run it finds a match, our nullary function declaration, and therefore it: - Ends regular unqualified name lookup, and since it found a regular function - Begins argument dependent lookup Note that the latter is what we actually want. Also note that when we call run we call it unary (with one argument) which means the poison pill we found will get ruled out by overload resolution. Therefore while regular unqualified name lookup does occur we manipulate the results it generates so it's as if it doesn't happen, thereby fulfilling the requirements laid out in text/standardese on the slide before.
The Joker kisses Harley Quinn underwater!#Harley Quinn #joker
00:49
Harley Quinn with the Joker
Рет қаралды 16 МЛН
Пройди игру и получи 5 чупа-чупсов (2024)
00:49
Екатерина Ковалева
Рет қаралды 4,2 МЛН
If Barbie came to life! 💝
00:37
Meow-some! Reacts
Рет қаралды 77 МЛН
Cute kitty gadgets 💛
00:24
TheSoul Music Family
Рет қаралды 16 МЛН
C++ Should Be C++ - David Sankel - C++Now 2024
1:28:49
CppNow
Рет қаралды 14 М.
Delivering Safe C++ - Bjarne Stroustrup - CppCon 2023
1:29:16
Harder Than It Seems? 5 Minute Timer in C++
20:10
The Cherno
Рет қаралды 167 М.
20 System Design Concepts Explained in 10 Minutes
11:41
NeetCode
Рет қаралды 975 М.
It’s time to move on from Agile Software Development (It's not working)
11:07
The Joker kisses Harley Quinn underwater!#Harley Quinn #joker
00:49
Harley Quinn with the Joker
Рет қаралды 16 МЛН