Calling Functions A TutorialCalling Functions A Tutorial Klaus Iglberger, CppCon 2020 klaus.iglberger@gmx.de2 Klaus Iglberger C++ Trainer since 2016 Author of the C++ math library (Co-)Organizer of the Munich Two-Phase Lookup Template Argument Deduction SFINAE Overload Resolution (Viable) Candidate Functions Ranking Ambiguous Function Calls Access Labels Function Template Specializations Virtual Two-Phase Lookup Template Argument Deduction SFINAE Overload Resolution (Viable) Candidate Functions Ranking Ambiguous Function Calls Access Labels Function Template Specializations Virtual0 码力 | 111 页 | 5.11 MB | 6 月前3
Back To Basics Functionsfor many years -- please provide suggestions, analogies, and other useful ways to think about functions now or in the future!Please do not redistribute slides without prior permission. 4Your Tour Guide for the talk ● Located here: https://github.com/MikeShah/Talks/tree/main/2023/cppcon/functions 6Abstract Functions are one of the first things programmers learn, granting you the ultimate power to 'reuse' overview of functions from the start to the end, on the various powers that are given to us from the ground up. Consider this talk your one stop for learning all of the great things about functions! We'll0 码力 | 123 页 | 7.26 MB | 6 月前3
From Functions to CoroutinesFrom Functions to Coroutines 40 Years Evolution Rainer Grimm Training, Coaching, and Technology Consulting www.ModernesCpp.netEvolution of Callable templateT invoke(Func sequence of functions can be changed ▪ Automatically parallelizable ▪ Results can be cachedPure Functions Working with a pure function is based on discipline Use common functions, meta-functions, constexpr constexpr, or consteval functions ▪ Function int powFunc(int m, int n){ if (n == 0) return 1; return m * powFunc(m, n - 1); } ▪ Meta-Function template struct PowMeta { static int const value 0 码力 | 29 页 | 510.47 KB | 6 月前3
C++20 镶 SQLC++20 ❤ SQL John R Bandela, MDOverview u SQL u C++ Example u Implementation techniques u fixed_string u meta_struct u Parsing compile time strings into meta_structsOverview v SQL v C++ Example {price_from_user};Avoiding SQL Injection Attacks SELECT orders.id, name, item, price, discount_code FROM orders JOIN customers ON customers.id = customerid WHERE price > ?;SQL Library Options u Traditional Lots of information available u Vulnerable to sql injection of developer not careful u Use dynamic typingDomain Specific Language u Use types to encode SQL u Looks more like regular C++ u Typically requires0 码力 | 46 页 | 775.02 KB | 6 月前3
Optimizing Away Virtual Functions May Be Pointlessvirt_duration = end-start;There are interesting technical details and surprising conclusions that virtual functions can be actually faster. Since CPU architectures are mentioned, I'd expect to see deep assembly eritance-vs-other- ways-performanceDoes it even matter?Conclusions ● The notion that “virtual functions are slower” is flat out wrong. ○ Which is not to say they are faster ○ Some of the suggested0 码力 | 20 页 | 1.19 MB | 6 月前3
Combining Co-Routines and Functions into a Job SystemHelmut Hlavacs – Combining Co-Routines and Functions into a Job System - CppCon 2021 1 / 39Helmut Hlavacs – Combining Co-Routines and Functions into a Job System - CppCon 2021 2 / 39 About Myself • Professor Processing) Technical Committee 14 Entertainment ComputingHelmut Hlavacs – Combining Co-Routines and Functions into a Job System - CppCon 2021 3 / 39 Creating Game Engines with C++ • Vienna Game Job System Vulkan Game Engine 2.0 https://github.com/hlavacs 20Helmut Hlavacs – Combining Co-Routines and Functions into a Job System - CppCon 2021 4 / 39 The Game Loop auto prev = high_resolution_clock::now();0 码力 | 39 页 | 1.23 MB | 6 月前3
Monadic Operations in Modern C++: A Practical Approachreturn std::nullopt; ./ If not found } 13std::optional as a parameter When you need to pass some auxiliary arguments: Url resolveUrl( std::string_view input, std::optionalconfiguration transform(&Widget::id); }Observations ● Functional programming is difficult for many ● Combining functions using “monadic operations” is not straightforward ● std::optional and std::expected is terra incognita projectLambda functions ● Lambda functions are flexible and powerful tool ● With noisy syntax ● And this is yet another footgun Use less: ● Nested lambda functions ● Long lambda functions ● Lambda functions 0 码力 | 61 页 | 411.49 KB | 6 月前3
Many Ways to Kill an Orc (or a Hero)services as our own 27What this is about? • Private inheritance means client code (other than friend functions and classes) cannot fully use the base-derived relationship #include// ... st we plan for a diamond-shaped inheritance 60 We removed constexpr from a few of our member functions, as constexpr construction and virtual base classes don’t agree much (sadly)A first attempt… are even upsides to this approach • Teachable (many are familiar with inheritance and virtual functions) • Structural commonality, which lets us write such things as: // group various Bellicose entities 0 码力 | 202 页 | 1.26 MB | 6 月前3
cppcon 2021 safety guidelines for C parallel and concurrencyapplication requiring all compute resources of a powerful multi-core CPU and possibly a number of auxiliary hardware accelerators. Fully fledged OS at the bottom. ⇒ Lots of concurrency, asynchronous APIs ref) -> auto { shared_data.mtx.lock(); // WARNING: Do not call member functions of std::mutex shared_data.update_rate = f.get(); // get() may throw! shared_data.mtx.unlock(); 0 码力 | 52 页 | 3.14 MB | 6 月前3
Conan 1.30 Documentationattributes are evaluated in the local directory context (see scm attribute), you can write more complex functions to retrieve the proper values, this source conanfile.py will be valid too: import os from conans changed, but without affecting the my_lib/1.0 binary for any reason (like changes consisting on new functions not used by my_lib). The same reasoning would apply if MyOtherLib was only the header. But what new methods to the public headers will have no impact, but changing the implementation of some functions that will be inlined when compiled from my_lib/1.0 will definitely require re-building. For this0 码力 | 715 页 | 5.39 MB | 1 年前3
共 268 条
- 1
- 2
- 3
- 4
- 5
- 6
- 27













