http://modernescpp.com/index.php/partial-function-application Search ...[ ] * Modernes C++ Partial Function Application 8 January 2023 Tweet Contents[Show] * + Currying + std::bind + Lambda Expressions + std::bind_front + What's Next? Partial Function Application is a technique in which a function binds a few of its arguments and returns a function taking fewer arguments. This technique is related to a technique used in functional languages called currying. GeneralIdioms A few weeks ago, I had a discussion with a few of my readers. One reader said that I should write about Partial Function Applications. Another reader mentioned that C++ does not support function applications. This is wrong. C++ supports Partial Function Application. Consequently, I am writing today about std::function, std::bind, std::bind_front, lambdas, auto, and currying. Let me start with a bit of theory. Currying Partial Function application is quite similar to a technique called currying. Currying is a well-known technique used in functional languages such as Haskell. It stands for a technique in which a function that takes more than one argument will successively be transformed into a series of functions taking only one argument. Therefore, a programming language such as Haskell has only functions taking one argument. I hear your question. How is it possible to implement a function such as add which needs two arguments? The magic is happening implicitly. Functions that need n arguments are transformed into functions returning a function that only needs n -1 arguments. The first element is evaluated in this transformation. The name currying is coined by the mathematician Haskell Curry and Moses Schonfinkel. Currying is named after the family name of Haskell Curry; Haskell after his first name. Sometimes, currying is also called schonfinkeln. Partial Function Application is more powerful than currying because you can evaluate arbitrary function arguments. Since C++11, C++ supports std::function and std::bind. std::bind std::bind enables you to create callables in various ways. You can * bind function argument at arbitrary positions, * reorder the sequence of the function arguments, * introduce placeholders for function arguments, * partially evaluate functions. Furthermore, you can * directly invoke the new callable, * use the callable in an algorithm of the Standard Template Library (STL), * store the callable in std::function. Before I show you an example, I have to introduce std::function: * std::function is a polymorphic function wrapper. It can take arbitrary callables and give them a name. Callables are all entities that behave like a function. In particular, these are lambda expressions, function objects, or functions themselves. std::function is required if you have to specify the type of a callable. Now, I'm done with the theory and can show an example of Partial Function Application: // bindAndFunction.cpp #include #include double divMe(double a, double b){ return double(a/b); } using namespace std::placeholders; // (1) int main(){ std::cout << '\n'; // invoking the function object directly std::cout << "1/2.0= " << std::bind(divMe, 1, 2.0)() << '\n'; // (2) // placeholders for both arguments // (3) std::function myDivBindPlaceholder= std::bind(divMe, _1, _2); std::cout << "1/2.0= " << myDivBindPlaceholder(1, 2.0) << '\n'; // placeholders for both arguments, swap the arguments // (4) std::function myDivBindPlaceholderSwap= std::bind(divMe, _2, _1); std::cout << "1/2.0= " << myDivBindPlaceholderSwap(2.0, 1) << '\n'; // placeholder for the first argument // (5) std::function myDivBind1St= std::bind(divMe, _1, 2.0); std::cout<< "1/2.0= " << myDivBind1St(1) << '\n'; // placeholder for the second argument // (6) std::function myDivBind2Nd= std::bind(divMe, 1.0, _1); std::cout << "1/2.0= " << myDivBind2Nd(2.0) << '\n'; std::cout << '\n'; } In order to use the simple notation _1, _2 for the placeholders std::placeholders::_1, std::placeholders::_2 in the source code, I have to introduce the namespace std::placeholders in line 1. I bind in line 2 in the expression std::bind(divMe, 1, 2.0) the arguments 1 and 2.0 to the function divMe and invoke them in place. Lines 3, 4, 5, and 6 follow a similar strategy, but I give the created callables a name using std::function, and invoke them finally. A template signature like double(double, double) (line 4) or double(double) (lines 5 and 6) stands for the type of callable that std::function accepts. double(double, double) is a function taking two doubles and returning a double. In particular, the last two examples (lines 5 and 6) in which std::function gets a function of arity two and returns a function of arity one is quite astonishing. The arity of a function is the number of arguments a function gets. std::bind evaluates in both calls only one argument and uses for the non-evaluated one a placeholder. This technique is called Partial Function Application. In the end, here is the output of the program. bindAndFunction There is another way in C++11 to use Partial Function Application: lambda expressions. Rainer D 6 P2 540x540Modernes C++ Mentoring Stay informed about my mentoring programs. Subscribe for the news. * + o # @ - = "Fundamentals for C++ Professionals" (open) * + o # @ - = "Design Patterns and Architectural Patterns with C++" (starts 24/02/2023) Thank you! Please check your email and confirm the newsletter subscription. Your subscription was updated Email * [ ] It seems that you have already subscribed to this list. Click here to update your profile. Subscribe Loading Lambda Expressions std::bind and std::function are almost superfluous with C++11. You can use lambda expressions instead of std::bind, and almost always auto instead of std::function. Here is the equivalent program based on auto, and lambda expressions. // lambdaAndAuto.cpp #include #include double divMe(double a, double b){ return double(a/b); } using namespace std::placeholders; int main(){ std::cout << '\n'; // invoking the function object directly std::cout << "1/2.0= " << [](int a, int b){ return divMe(a, b); }(1, 2.0) << '\n'; // placeholders for both arguments auto myDivBindPlaceholder= [](int a, int b){ return divMe(a, b); }; std::cout << "1/2.0= " << myDivBindPlaceholder(1, 2.0) << '\n'; // placeholders for both arguments, swap the arguments auto myDivBindPlaceholderSwap= [](int a, int b){ return divMe(b, a); }; std::cout << "1/2.0= " << myDivBindPlaceholderSwap(2.0, 1) << '\n'; // placeholder for the first argument auto myDivBind1St= [](int a){ return divMe(a, 2.0); }; std::cout<< "1/2.0= " << myDivBind1St(1) << '\n'; // placeholder for the second argument auto myDivBind2Nd= [](int b){ return divMe(1, b); }; std::cout << "1/2.0= " << myDivBind2Nd(2.0) << '\n'; std::cout << '\n'; } Let me say write a few words about the lambda expressions. The expression [](int a, int b){ return divMe(a, b); }(1, 2.0) defines a lambda exepression that executes divMe. The trailing braces invoke the lambda expression just in place using the arguments 1 and 2.0. On the contrary, the remaining lambda expressions are invoked in the subsequent lines. You can use a lambda expression to bind any argument of the underlying function. So far, I have applied Partial Function application with std::bind and lambda expressions. In C++20, there is a new variation of std::bind: std::bind_front std::bind_front creates a callable. std::bind_front can have an arbitrary number of arguments and binds its arguments to the front. You may wonder why we have std::bind_front because we have since C++11 std::bind, which can also bind to the front. Here is the point. First, std::bind_front is easier to use because it does not need placeholders, and second, std::bind_front propagates an exception specification of the underlying callable. The following program exemplifies that you can replace std::bind_front with std::bind, or lambda expressions. // bindFront.cpp #include #include int plusFunction(int a, int b) { return a + b; } auto plusLambda = [](int a, int b) { return a + b; }; int main() { std::cout << '\n'; auto twoThousandPlus1 = std::bind_front(plusFunction, 2000); // (1) std::cout << "twoThousandPlus1(20): " << twoThousandPlus1(20) << '\n'; auto twoThousandPlus2 = std::bind_front(plusLambda, 2000); // (2) std::cout << "twoThousandPlus2(20): " << twoThousandPlus2(20) << '\n'; auto twoThousandPlus3 = std::bind_front(std::plus(), 2000); // (3) std::cout << "twoThousandPlus3(20): " << twoThousandPlus3(20) << '\n'; std::cout << "\n\n"; using namespace std::placeholders; auto twoThousandPlus4 = std::bind(plusFunction, 2000, _1); // (4) std::cout << "twoThousandPlus4(20): " << twoThousandPlus4(20) << '\n'; auto twoThousandPlus5 = [](int b) { return plusLambda(2000, b); }; // (5) std::cout << "twoThousandPlus5(20): " << twoThousandPlus5(20) << '\n'; std::cout << '\n'; } Each call (lines 1 - 5) gets a callable taking two arguments and returns a callable taking only one argument because the first argument is bound to 2000. The callable is a function (1), a lambda expression (2), and a predefined function object (line 3). _1 stands for the missing argument. With lambda expression (line 5), you can directly apply one argument and provide an argument b for the missing parameter. Regarding readability, is std::bind_front easier to use than std::bind, or a lambda expression. bindFront What's Next? Argument-Dependent Lookup (ADL), also known as Koening Lookup is a set of "magical" rules for the lookup of unqualified functions based on their function arguments. Thanks a lot to my Patreon Supporters: Matt Braun, Roman Postanciuc, Tobias Zindl, G Prvulovic, Reinhold Droge, Abernitzke, Frank Grimm, Sakib, Broeserl, Antonio Pina, Sergey Agafyin, Andrei Burmistrov, Jake, GS, Lawton Shoemake, Animus24, Jozo Leko, John Breland, Venkat Nandam, Jose Francisco, Douglas Tinkham, Kuchlong Kuchlong, Robert Blanch, Truels Wissneth, Kris Kafka, Mario Luoni, Friedrich Huber, lennonli, Pramod Tikare Muralidhara, Peter Ware, Daniel Hufschlager, Alessandro Pezzato, Evangelos Denaxas, Bob Perry, Satish Vangipuram, Andi Ireland, Richard Ohnemus, Michael Dunsky, Leo Goodstadt, John Wiederhirn, Yacob Cohen-Arazi, Florian Tischler, Robin Furness, Michael Young, Holger Detering, Bernd Muhlhaus, Matthieu Bolt, Stephen Kelley, Kyle Dean, Tusar Palauri, Dmitry Farberov, Juan Dent, George Liao, Daniel Ceperley, Jon T Hess, Stephen Totten, Wolfgang Futterer, Matthias Grun, and Phillip Diekmann. Thanks in particular to Jon Hess, Lakshman, Christian Wittenhorst, Sherhy Pyton, Dendi Suhubdy, Sudhakar Belagurusamy, Richard Sargeant, Rusty Fleming, Ralf Abramowitsch, John Nebel, Mipko, and Alicja Kaminska. My special thanks to Embarcadero CBUIDER STUDIO FINAL ICONS 1024 Small My special thanks to PVS-Studio PVC Logo Seminars I'm happy to give online seminars or face-to-face seminars worldwide. Please call me if you have any questions. Bookable (Online) German * Embedded Programmierung mit modernem C++ 31.01.2023 - 02.02.2023 (Termingarantie / Prasenzschulung) * C++20: 18.04.2023 - 20.04.2023 (Prasenzschulung) * Clean Code: Best Practices fur modernes C++: 20.06.2023 - 22.06.2023 (Prasenzschulung) * Design Pattern und Architekturpattern mit C++: 22.08.2023 - 24.08.2023 (Prasenzschulung) Standard Seminars (English/German) Here is a compilation of my standard seminars. These seminars are only meant to give you a first orientation. * C++ - The Core Language * C++ - The Standard Library * C++ - Compact * C++11 and C++14 * Concurrency with Modern C++ * Design Pattern and Architectural Pattern with C++ * Embedded Programming with Modern C++ * Generic Programming (Templates) with C++ New * Clean Code with Modern C++ * C++20 Contact Me * Phone: +49 7472 917441 * Mobil:: +49 176 5506 5086 * Mail: This email address is being protected from spambots. You need JavaScript enabled to view it. * German Seminar Page: www.ModernesCpp.de * English Seminar Page: www.ModernesCpp.net * Mentoring Page: www.ModernesCpp.org Modernes C++, RainerGrimmDunkelBlauSmall Tweet Add comment JComments Mentoring * Fundamentals for C++ Professionals * Design Patterns and Architectural Patterns for C++ Stay Informed about my Mentoring English Books * C++ Core Guidelines Explained * C++20 * Concurrency With Modern C++ * The C++ Standard Library Course: Modern C++ Concurrency in Practice * Modern C++ Concurrency in Practice Course: C++ Standard Library including C++14 & C++17 * C++ Standard Library including C++14 & C++17 Course: Embedded Programming with Modern C++ * Interactive Course: Embedded Course: Generic Programming (Templates) * Interactive Course: Templates Course: C++ Fundamentals for Professionals * Interactive Course: C++ Fundamentals for Professionals Interactive Course: The All-in-One Guide to C++20 * Interactive Course: The All-in-One Guide to C++20 More Profiles * Training, coaching, and technology consulting * Modernes C++ Mentoring Contact * rainer@grimm-jaud.de * Impressum * Become a Patron Subscribe to the newsletter (+ pdf bundle) Email [ ] Please enable the javascript to submit this form [Subscribe] * Modernes C++ * Visual Tour Categories * C++17 * C++20 * C++23 * C++ Core Guidelines * C++ Insights * Embedded * Functional * Multithreading * Multithreading - Application * Multithreading - C++17 and C++20 * Multithreading - Memory Model * Patterns * Templates * News * Overview * Pdf bundles * Review * Mentoring All tags * acquire-release semantic * arithmetic * associative containers * async * atomics * atomic_thread_fence * auto * bit manipulation * C * C++17 * C++20 * class hierarchies * classes * concepts * condition variables * constexpr * contracts * conversions * coroutines * CppMem * declarations * decltype * enum * error handling * exceptions * expressions * final * finally * functions * Guideline Support Library * if * initialisations * inline * interfaces * lambdas * lock * lock-free * memory * memory_order_consume * modules * move * mutex * new/delete * noexcept * nullptr * Ongoing Optimization * overloading * override * performance * pointers * ranges library * relaxed semantic * semaphores * sequential consistency * shared_ptr * singleton * smart pointers * source files * spaceship * statements * static * static_assert * string * switch * tasks * template metaprogramming * templates * ThreadSanitizer * thread_local * time * type erasure * type-traits * unique_ptr * user-defined literals * vector * volatile * weak_ptr Blog archive * > 2022 (75) + > December (4) o An Interview that went Viral o Early Bird Price for my Mentoring Program "Design Patterns and Architectural Patterns with C++" o Webinar: C++ with Python for Algorithmic Trading o Registration is Open for my Mentoring Program "Design Patterns and Architectural Patterns with C++" + > October (10) o Partial Function Application o The Copy-and-Swap Idiom o The Strategy Pattern o And the Five Winners for "Template Metaprogramming with C++" are o The Template Method o The Visitor Pattern o The Observer Pattern o The Proxy Pattern o Five Coupons for the eBook "Template Metaprogramming with C++" o The Facade Pattern + > September (9) o The Composite Pattern o Concepts and the Finance Industry o The Decorator Pattern o The Bridge Pattern o The Adapter Pattern o The Singleton: The Alternatives Monostate Pattern and Dependency Injection o The Singleton: Pros and Cons o Stop Training, Start Mentoring o The Factory Method (Slicing and Ownership Semantics) + > August (7) o The Singleton o The Factory Method o Anti-Patterns o And the Five Winners for the "C++20 STL Cookbook" are o About Algorithms, Frameworks, and Pattern Relations o The Structure of Patterns o Classification of Patterns + > July (6) o Five Giveaway eBooks for "C++20 STL Cookbook" o Classification of Design Patterns o And the Five Winners for "C++ Core Guidelines: Best Practices for Modern C++" o Training or Mentoring: What's the Difference? o C++ Core Guidelines Explained: Best Practices for Modern C++ o The History of Patterns + > June (7) o The Advantages of Patterns o I'm Nominated for the "2022 Business Worldwide CEO Awards" o Design Patterns and Architectural Patterns with C++: A First Overview o Ranges Improvements with C++23 o My Next Mentoring Program is "Design Patterns and Architectural Patterns with C++" o Improved Iterators with Ranges o My Next Mentoring Program + > May (5) o Sentinels and Concepts with Ranges Algorithms o Projections with Ranges o The Ranges Library in C++20: More Details o Check Types with Concepts o Check Types with Concepts - The Motivation + > April (6) o Using Requires Expression in C++20 as a Standalone Feature o Defining Concepts with Requires Expressions o C++ 20 Techniques for Algorithmic Trading o Define Concepts o Type Erasure o 10 Days Left to Register Yourself for my Mentoring Program "Fundamentals for C++ Professionals" + > March (9) o A std::advance Implementation with C++98, C++17, and C++20 o A Sample for my Mentoring Program "Fundamentals for C++ Professionals" o Software Design with Traits and Tag Dispatching o Registration is Open for my Mentoring Program "Fundamentals for C++ Professionals" o Policy o Avoiding Temporaries with Expression Templates o Help for the People in Ukraine o Mixins o The Launch of my Mentoring Program "Fundamentals for C++ Professionals" + > February (6) o More about Dynamic and Static Polymorphism o More About Me o Dynamic and Static Polymorphism o constexpr if o constexpr and consteval Functions in C++20 o More Information about my Mentoring Program "Fundamentals for C++ Professionals" + > January (6) o constexpr Functions o An Update of my Book "Concurrency with Modern C++" o The New pdf Bundle is Ready: C++20 Concurreny - The Hidden Pearls o Dining Philosophers Problem III o Dining Philosophers Problem II o Dining Philosophers Problem I * > 2021 (65) + > December (5) o My Mentoring Program "Fundamentals for C++ Professionals" o Which pdf bundle do you want? Make your choice! o The Type-Traits Library: Optimization o The Type-Traits Library: Correctness o The Type-Traits Library: std::is_base_of + > November (6) o The Type-Traits Library: Type Comparisons o And the Winners for the Seven Vouchers for Fedor's Book "The Art of Writing Efficient Programs" are o The Type-Traits Library: Type Checks o Template Metaprogramming - Hybrid Programming o Seven Voucher for Fedor G. Pikus Book "The Art of Writing Efficient Programs" o Template Metaprogramming - How it Works + > October (4) o Template Metaprogramming - How it All Started o Automatic Return Type (C++11/14/20) o Automatic Return Type (C++98) o Dependent Names + > September (7) o The Special Friendship of Templates o Visiting a std::variant with the Overload Pattern o Smart Tricks with Parameter Packs and Fold Expressions o The New pdf Bundle is Ready: C++20 Modules o Modern C++ Collection o From Variadic Templates to Fold Expressions o C++20 Modules: Private Module Fragment and Header Units + > August (4) o The First Big Update of My C++20 Book o Which pdf bundle do you want? Make your choice! o More about Variadic Templates ... o Variadic Templates or the Power of Three Dots + > July (6) o Template Instantiation o And the Winners for the Five Vouchers for Stephan's Book "Clean C++20" are o Performance of the Parallel STL Algorithms o Parallel Algorithms of the STL with the GCC Compiler o Five Vouchers for Stephan Roth's Book "Clean C++20" to Win o Full Specialization of Function Templates + > June (7) o Template Specialization - More Details About Class Templates o Template Specialization o Template Argument Deduction of Class Templates o The New pdf Bundle is Ready: C++20 Coroutines o Template Arguments o Alias Templates and Template Parameters o "Concurrency with Modern C++" Update to C++20 + > May (5) o Surprise Included: Inheritance and Member Functions of Class Templates o Class Templates o Which pdf bundle do you want? Make your choice! o Function Templates - More Details about Explicit Template Arguments and Concepts o Function Templates + > April (4) o Templates - First Steps o Printed Version of C++20 & Source Code on GitHub o And The Winner is: Templates o Quo Vadis - Modernes C++ + > March (6) o Automatically Resuming a Job with Coroutines on a Separate Thread o Starting Jobs with Coroutines o A Generic Data Stream with Coroutines in C++20 o An Infinite Data Stream with Coroutines in C++20 o Executing a Future in a Separate Thread with Coroutines o Lazy Futures with Coroutines + > February (6) o Implementing Simple Futures with Coroutines o Synchronized Output Streams with C++20 o The Five (Seven) Winners of my C++20 book are: o An Improved Thread with C++20 o Resolving C/C++ Concurrency Bugs More Efficiently with Time Travel Debugging o Cooperative Interruption of a Thread in C++20 + > January (5) o Barriers and Atomic Smart Pointers in C++20 o Latches in C++20 o Semaphores in C++20 o And the Winners are: o Five Vouchers to win for my book "C++20" * > 2020 (60) + > December (6) o Performance Comparison of Condition Variables and Atomics in C++20 o I'm Proud to Present my New Book: C++20 o Synchronization with Atomics in C++20 o Atomic References with C++20 o Looking for Proofreaders for my New Book: C++20 o Bit Manipulation with C++20 + > November (3) o Feature Testing with C++20 o Safe Comparisons of Integrals with C++20 o Calendar and Time-Zones in C++20: Calendar Dates + > October (6) o Calendar and Time-Zones in C++20: Time-Zones o Calendar and Time-Zones in C++20: Handling Calendar Dates o Calendar and Time-Zones in C++20: Time of Day o More and More Utilities in C++20 o C++20: Extend std::format for User-Defined Types o std::format in C++20 + > September (4) o More Convenience Functions for Containers with C++20 o constexpr std::vector and std::string in C++20 o std::span in C++20: Bounds-Safe Views for Sequences of Objects o And the Winners are: + > August (6) o Five Vouchers to win for the book "Modern C++ for Absolute Beginners" o volatile and Other Small Improvements in C++20 o New Attributes with C++20 o Compiler Explorer, PVS-Studio, and Terrible Simple Bugs o More Lambda Features with C++20 o The C++ Standard Library: The Third Edition includes C++20 + > July (5) o More Powerful Lambdas with C++20 o Various Template Improvements with C++20 o Solving the Static Initialization Order Fiasco with C++20 o Two new Keywords in C++20: consteval and constinit o Designated Initializers + > June (4) o C++20: Optimized Comparison with the Spaceship Operator o C++20: More Details to the Spaceship Operator o C++20: The Three-Way Comparison Operator o C++20: Further Open Questions to Modules + > May (7) o C++20: Structure Modules o C++20: Module Interface Unit and Module Implementation Unit o C++20: A Simple math Module o Modernes C++ goes Worldwide o C++20: The Advantages of Modules o Face-to-Face Seminars and Online Seminars are different o C++20: Thread Pools with cppcoro + > April (5) o C++20: Powerful Coroutines with cppcoro o C++20: Coroutines with cppcoro o Four Voucher for Educative o C++20: Thread Synchronization with Coroutines o C++20: An Infinite Data Stream with Coroutines + > March (6) o C++20: More Details to Coroutines o Looking for Proofreaders for my new Book: C++ Core Guidelines o C++20: Coroutines - A First Overview o My Personal Words about Corona o C++20: Python's map Function o C++20: Pythons range Function, the Second + > February (4) o C++20: Pythonic with the Ranges Library o C++20: Functional Patterns with the Ranges Library o C++20: The Ranges Library o Concepts in C++20: An Evolution or a Revolution? + > January (4) o C++20: Define the Concept Regular and SemiRegular o C++20: Define the Concepts Equal and Ordering o C++20: Define Concepts o C++20: Concepts - Predefined Concepts * > 2019 (57) + > December (4) o C++20: Concepts - What we don't get o C++20: Concepts - Syntactic Sugar o A Brief Overview of the PVS-Studio Static Code Analyzer o C++20: Concepts, the Placeholder Syntax + > November (2) o C++20: Concepts, the Details o C++20: Two Extremes and the Rescue with Concepts + > October (9) o C++20: Concurrency o C++20: The Library o C++ 20: The Core Language o C++20: The Big Four o The new pdf bundle is ready: C++ Core Guidelines: Performance o The Next Big Thing: C++20 o "Concurrency with Modern C++" has a new chapter o C++ Core Guidelines: Naming and Layout Rules o C++ Core Guidelines: Lifetime Safety And Checking the Rules + > September (4) o C++ Core Guidelines: Bounds Safety o C++ Core Guidelines: Type Safety by Design o C++ Core Guidelines: Type Safety o C++ Core Guidelines: Profiles + > August (6) o More Myths of My Blog Readers o Which pdf bundle should I provide? Make your choice! o Myths of My Blog Readers o C++ Core Guidelines: More Non-Rules and Myths o C++ Core Guidelines: Non-Rules and Myths o C++ Core Guidelines: Supporting Sections + > July (4) o C++ Core Guidelines: When RAII breaks o More Rules about the Regular Expression Library o The Regular Expression Library o C++ Core Guidelines: Improved Performance with Iostreams + > June (4) o Stuff you should know about In- and Output with Streams o C++ Core Guidelines: IOstreams o C++ Core Guidelines: Rules for Strings o C++ Core Guidelines: Avoid Bounds Errors + > May (4) o More special Friends with std::map and std::unordered_map o C++ Core Guidelines: std::array and std::vector are your Friends o C++ Core Guidelines: The Standard Library o More Details to Modules + > April (6) o Modules o C++ Core Guidelines: The Remaining Rules about Source Files o The new pdf bundle is available: C++ Core Guidlines - Templates and Generic Programming o C++ Core Guidelines: Source Files o C++ Insights - Lambdas o C++ Insights - Variadic Templates + > March (5) o C++ Insights - Template Instantiation o C++ Insights - Type Deduction o Which pdf bundle should I provide? Make your choice! o C++ Insights - Implicit Conversions o C++ Core Guidelines: Mixing C with C++ + > February (5) o Types-, Non-Types, and Templates as Template Parameters o Templates: Misconceptions and Surprises o C++ Core Guidelines: Surprise included with the Specialisation of Function Templates o C++ Core Guidelines: Other Template Rules o C++ Core Guidelines: Programming at Compile Time with constexpr + > January (4) o C++ Core Guidelines: Programming at Compile Time with Type-Traits (The Second) o C++ Core Guidelines: Programming at Compile Time with the Type-Traits o C++ Core Guidelines: Programming at Compile Time o C++ Core Guidelines: Rules for Template Metaprogramming * > 2018 (62) + > December (5) o CppDepend - A Review o C++ Core Guidelines: Rules for Variadic Templates o C++ Core Guidelines: Rules for Templates and Hierarchies o C++ Core Guidelines: Ordering of User-Defined Types o C++ Core Guidelines: Template Definitions + > November (5) o C++ Core Guidelines: Surprises with Argument-Dependent Lookup o C++ Core Guidelines: Regular and SemiRegular Types o Meeting Embedded and Meeting C++ 2018 o C++ Core Guidelines: Template Interfaces o C++ Core Guidelines: Pass Function Objects as Operations + > October (5) o I'm Proud to Present: The C++ Standard Library including C++14 & C++17 o C++ Core Guidelines: Definition of Concepts, the Second o A new Thread with C++20: std::jthread o C++ Core Guidelines: Rules for the Definition of Concepts o C++ Core Guidelines: Rules for the Usage of Concepts + > September (4) o CppCon 2018 o C++ Core Guidelines: Better Specific or Generic? o C++ Core Guidelines: Type Erasure with Templates o C++ Core Guidelines: Type Erasure + > August (8) o C++ Core Guidelines: Rules for Templates and Generic Programming o C++ Core Guidelines: Rules for Constants and Immutability o The new pdf bundle is ready: C++ Core Guidelines - Concurrency and Parallelism o C++ Core Gudelines: goto considered Evil o For Free: Four Vouchers to Win o C++ Core Guidelines: finally in C++ o I'm Proud to Present: Modern C++ Concurrency is available as interactive course o C++ Core Guidelines: Rules about Exception Handling + > July (5) o C++ Core Guidelines: The noexcept Specifier and Operator o C++ Core Guidelines: A Short Detour to Contracts in C++20 o C++ Core Guidelines: Rules for Error Handling o Which pdf bundle should I provide? Make your choice! o C++ Core Guidelines: The Remaining Rules about Lock-Free Programming + > June (6) o C++ Core Guidelines: The Resolution of the Riddle o C++ Core Guidelines: Concurrency and lock-free Programming o The End of my Detour: Unified Futures o The Update of my Book "Concurreny with Modern C++" o A Short Detour: Executors o C++ Core Guidelines: Be Aware of the Traps of Condition Variables + > May (4) o C++ Core Guidelines: More Traps in the Concurrency o C++ Core Guidelines: Taking Care of your Child Thread o C++ Core Guidelines: Sharing Data between Threads o C++ Core Guidelines: Use Tools to Validate your Concurrent Code + > April (6) o C++ Core Guidelines: More Rules about Concurrency and Parallelism o C++ Core Guidelines: Rules for Concurrency and Parallelism o The new pdf bundle is ready: Functional Features in C++ o C++ Core Guidelines: The Remaining Rules about Performance o C++ Core Guidelines: More Rules about Performance o The Truth about "Raw Pointers Removed from C++" + > March (6) o No New New: Raw Pointers Removed from C++ o C++ Core Guidelines: Rules about Performance o Which pdf bundle should I provide? Make your choice! o C++ Core Guidelines: Rules about Statements and Arithmetic o C++ Core Guidelines: More about Control Structures o C++ Core Guidelines: To Switch or not to Switch, that is the Question + > February (4) o C++ Core Guidelines: Rules for Statements o C++ Core Guidelines: Rules about Don'ts o C++ Core Guidelines: Rules for Conversions and Casts o C++ Core Guidelines: More Rules for Expressions + > January (4) o C++ Core Guidelines: Rules for Expressions o C++ Core Guidelines: More Rules for Declarations o C++ Core Guidelines: Declarations and Initialisations o Clean C++ * > 2017 (101) + > December (6) o C++ Core Guidelines: Rules for Expressions and Statements o C++ Core Guidelines: Passing Smart Pointers o C++ Core Guidelines: Rules for Smart Pointers o The new pdf bundle is available: Embedded - Performance Matters o C++ Core Guidelines: Rules for Allocating and Deallocating o C++ Core Guidelines: Rules about Resource Management + > November (6) o C++ Core Guidelines: Rules for Enumerations o Which pdf bundle should I provide? Make your choice! o C++ Core Guidelines: Rules for Unions o C++ Core Guidelines: More Rules for Overloading o C++ Core Guidelines: Rules for Overloading and Overload Operators o The C++ Standard Library: The Second Edition includes C++17 + > October (5) o C++ Core Guidelines: Accessing Objects in a Hierarchy o C++ Core Guidelines: The Remaining Rules about Class Hierarchies o The new pdf bundle is available: Functional Programming with C++17 and C++20 o C++ Core Guidelines: More Rules about Class Hierarchies o C++ Core Guidelines: Class Hierarchies + > September (8) o C++ Core Guidelines: Function Objects and Lambdas o Which pdf bundle should I provide? Make your choice! o C++ Core Guidelines: Comparison, Swap, and Hash o C++ Core Guidelines: Rules for Copy and Move o My open C++ Seminars in the First Half of 2018 o C++ Core Guidelines: Constructors o The new pdf bundle is ready: C++17 o C++ Core Guidelines: Destructor Rules + > August (7) o I Proudly present my Book is Ready "Concurrency with Modern C++" o C++ Core Guidelines: The Rule of Zero, Five, or Six o C++ Core Guidelines: Class Rules o Which pdf bundle should I provide? o C++ Core Guidelines: Semantic of Function Parameters and Return Values o C++ Core Guidelines: The Rules for in, out, in-out, consume, and forward Function Parameter o "Concurrency with Modern C++" is 95% complete; Including all Source Files + > July (6) o C++ Core Guidelines: Function Definitions o C++ Core Guideline: The Guideline Support Library o My Book "Concurrency with Modern C++" is 75% complete o C++ Core Guidelines: Interfaces II o C++ Core Guidelines: Interfaces I o My Book "Concurrency with Modern C++" is 50% complete + > June (9) o C++ Core Guidelines: The Philosophy o Get the Current Pdf Bundle: "Multithreading: The High-Level Interface" o My Book "Concurrency with Modern C++" is 30% complete o Why do we need Guidelines for Modern C++? o What is Modern C++? o The Winner is: Multithreading: The high-level Interface o ABA - A is not the same as A o Which pdf bundle should I provide? Make your cross! o Blocking and Non-Blocking Algorithms + > May (5) o Looking for Proofreaders for my new Book: Concurrency with Modern C++ o Malicious Race Conditions and Data Races o Race Conditions versus Data Races o C++17: Improved Associative Containers and Uniform Container Access o C++17: New Parallel Algorithms of the Standard Template Library + > April (7) o Get the Current Pdf Bundle: Concurrency with C++17 and C++20 o C++17 has a Visitor o The Winners of the Next Pdf Bundles o C++17 - Avoid Copying with std::string_view o Which pdf bundle should I provide? o C++17- std::byte and std::filesystem o C++17- More Details about the Core Language + > March (11) o C++17 - What's New in the Library? o How to get your pdf bundle? o C++17 - What's New in the Core Language? o And the Winners are: The C++ Memory Model/Das C++ Speichermodell o Defining Concepts o Placeholders - The Second o Concepts - Placeholders o Task Blocks o Transactional Memory o I'm Done - Geschafft: Words about the Future of my Blogs o Pdf Bundles + > February (15) o Coroutines o Latches And Barriers o std::future Extensions o And the Winners are o Atomic Smart Pointers o Parallel Algorithms of the Standard Template Library o Multithreading with C++17 and C++20 o Expression Templates o C++ is Lazy: CRTP o Six Vouchers to Win o Monads in C++ o Concepts o The New Ranges Library o Fold Expressions o Recursion, List Manipulation, and Lazy Evaluation + > January (16) o Pure Functions o Immutable Data o Higher-Order Functions o First-Class Functions o The Definition of Functional Programming o Functional in C++17 and C++20 o Functional in C++11 and C++14: Dispatch Table and Generic Lambdas o Functional in TR1 and C++11 o Functional in C++98 o Object-Oriented, Generic, and Functional Programming o Memory Pool Allocators by Jonathan Muller o Pros and Cons of the various Memory Allocation Strategies o Strategies for the Allocation of Memory o Improvements of this Blog o Memory Management with std::allocator o Overloading Operator new and delete 2 * > 2016 (97) + > December (16) o Overloading Operator new and delete 1 o Explicit Memory Management o Garbage Collection - No Thanks o Perfect Forwarding o Time for Wishes o Move Semantis: Two Nice Properties o Copy versus Move Semantics: A few Numbers o std::array - Dynamic Memory, no Thanks o Automatic Memory Management of the STL Containers o std::weak_ptr o Specialities of std::shared_ptr o std::shared_ptr o std::unique_ptr o Memory and Performance Overhead of Smart Pointers o Careful Handling of Resources o Generalized Plain Old Data + > November (12) o Buckets, Capacity, and Load Factor o Hash Functions o Associative Containers - A simple Performance Comparison o Hash Tables o Type-Traits: Performance Matters o constexpr Functions o constexpr - Variables and Objects o Constant Expressions with constexpr o inline o The Null Pointer Constant nullptr o override and final o Strongly-Typed Enums + > October (12) o Raw and Cooked o User-Defined Literals o Published at Leanpub: The C++ Standard Library o I'm proud to present: The C++ Standard Library o Compare and Modify Types o Check Types o More and More Save o Statically Checked o {}-Initialization o auto-matically inititialized o Facts o Myths + > September (10) o Requirements of Embedded Programming o Sleep and Wait o The Three Clocks o Time Duration o Time Point o The Time Library o My Conclusion: Summation of a Vector in three Variants o Multithreaded: Summation with Minimal Synchronization o Multithreaded: Summation of a Vector o Single Threaded: Summation of a Vector + > August (9) o Thread-Safe Initialization of a Singleton o Ongoing Optimization: Relaxed Semantic with CppMem o Ongoing Optimization: A Data Race with CppMem o Ongoing Optimization: Acquire-Release Semantic with CppMem o Ongoing Optimization: Sequential Consistency with CppMem o Ongoing Optimization: Locks and Volatile with CppMem o Ongoing Optimization: Unsynchronized Access with CppMem o Looking for Proofreaders for my New C++ Book o Ongoing Optimization + > July (10) o CppMem - An Overview o Relaxed Semantic o Acquire-Release Fences o Fences are Memory Barriers o Acquire-Release Semantic - The typical Misunderstanding o 100 Posts Anniversary - Quo vadis Modernes C++? o memory_order_consume o Transitivity of the Acquire-Release Semantic o Acquire-Release Semantic o Sequential Consistency applied + > June (12) o Synchronization and Ordering Constraints o The Atomic Boolean o Atomics o The Facebook Group Modernes C++ o The Atomic Flag o Sequential Consistency o C++ Memory Model o Thread Synchronization with Condition Variables or Tasks o Modernes C++ o The Special Futures o Promise and Future o Asynchronous Callable Wrappers + > May (9) o Asynchronous Function Calls o Tasks o Condition Variables o Thread-Local Data o Thread-Safe Initialization of Data o Reader-Writer Locks o Prefer Locks to Mutexes o Source Code Repository o The Risks of Mutexes + > April (7) o Threads Sharing Data o Threads Lifetime o Thread Arguments o For the Proofreaders and the Curious People o Thread Creation o Multithreading in Modern C++ o Why my Blog in English? Source Code * GitHub Facebook Googleplus Linkedin Twitter Xing Hunting Most Popular Posts * Thread-Safe Initialization of a Singleton (345053 hits) * C++ Core Guidelines: Passing Smart Pointers (310479 hits) * C++ Core Guidelines: Be Aware of the Traps of Condition Variables (293368 hits) * C++17 - Avoid Copying with std::string_view (258579 hits) * What is Modern C++? (252547 hits) Visitors Today 9445 Yesterday 4482 Week 9445 Month 54002 All 11148152 Currently are 505 guests and no members online Kubik-Rubik Joomla! Extensions Latest comments * C++20: Module Interface Unit and Module Implementation Unit learnedSloth Massively parallel builds maybe? Read more... * An Interview that went Viral learnedSloth > C++ is too big to fall. So were the tower of Babel, Rome and Soviet Russia. Read more... * C++17 - Avoid Copying with std::string_view Rainer Both calls use a C-string to initialize a C++-string. A C++-string is, in-general, stored on the ... Read more... * C++17 - Avoid Copying with std::string_view Max I donot see why line 28, 29 would cause a new in your first listing. Read more... * The Copy-and-Swap Idiom wood999 If you define correct copy and move constructors (and you probably do if you're defining operator=) then ... Read more... 1. You are here: 2. Home[arrow] 3. Partial Function Application Copyright (c) 2023 ModernesCpp.com. All Rights Reserved. Designed by JoomlArt.com. Joomla! is Free Software released under the GNU General Public License. Bootstrap is a front-end framework of Twitter, Inc. Code licensed under MIT License. Font Awesome font licensed under SIL OFL 1.1.