Tag: concepts

Using Modern C++ to Eliminate Virtual Functions – Jonathan Gopel – CppCon 2022

  • Lobby
  • Tag Archives: concepts

https://cppcon.org/
---

Using Modern C++ to Eliminate Virtual Functions - Jonathan Gopel - CppCon 2022
https://github.com/CppCon/CppCon2022

As of C++20, there are no cases in which statically linked programs require virtual functions. This talk will explore techniques for replacing runtime polymorphism with compile-time polymorphism such that virtual functions are never necessary. This talk will also address the higher-order concern of when it might make sense to avoid virtual functions or remove them from a codebase, as that decision ultimately is a design decision that only the author of the code can make. Attendees can expect to come away with a stronger understanding of the purposes of virtual functions and the mechanisms in modern C++ that can now be used to achieve those same purposes.
---

Jonathan Gopel

Jonathan is a C++ enthusiast who likes to tinker with the latest language features. He spends a lot of time thinking about designing beautiful, easy to use APIs, and believes that the hard part is interfacing with the humans, not the machines. In his spare time, Jonathan pursues outdoor sports - especially climbing, skiing, and running.
---

Videos Filmed & Edited by Bash Films: http://www.BashFilms.com
YouTube Channel Managed by Digital Medium Ltd https://events.digital-medium.co.uk

#cppcon #programming #functions

Filed under: UncategorizedTagged with: , , , , , , ,

Functional Composable Operations with Unix-Style Pipes in C++ – Ankur Satle – CppCon 2022

  • Lobby
  • Tag Archives: concepts

https://cppcon.digital-medium.co.uk/tag/cppcon/">cppcon.org/
---

Functional Composable Operations with Unix-Style Pipes in C++ - Ankur Satle - CppCon 2022
https://github.com/CppCon/CppCon2022

Let's write C++ code like this shaking off all the verbosity and with 100% domain code and ~0% syntax! Do we really need to explicitly state whether a function is a continuation or a transform?

return get_env("KafkaConsumerConfigFile")
| get_file_contents
| make_client
| connect
| subscribe;
Unix commands seamlessly compose, piping into each other to form a clear train of operations in one line! Similarly in C++, we moved away from non-composable, multi-step processing of ranges using algorithm. We embraced the composable ranges using pipes. This reduced time & space complexity, improved performance, provided clarity & reduced cognitive load when working with ranges.

But, when NOT dealing with std::ranges, can one work with such easy composability? Why not pipe operations to work with application/business entities! YES, of course, I say! Let's pipe application logic operations & get declarative! HOW HARD COULD IT BE!

With just C++11, we achieve piping operations for any generic T & a Callable. We address Error handling, Resource management, Customizations and Variations like chaining functions taking more than 1 argument or invoking a member function operation instead of free function. Supporting C++20, we make sure our pipe implementation does NOT interfere with std::ranges operations.

Finally, we address the proposed C++23 Monadic interface functions (and_then, transform, or_else) of std::optional and present how we can implement the same without having to explicitly state the verbose and_then, transform, or_else to work with optional. We encounter a surprise on the way & correct overload resolution by employing a concept.

We also discuss critique & compromises of this approach.
---

Ankur Satle

Ankur is an avid (natural) language learner, but C++ is his mother tongue!
His mantra is: "Effective, Efficient & Elegant". He leverages the power of the small to build large-scale systems. As Smart Data Platform Architect at EXFO, he builds High-performance, Scalable, Telecom Products for 4G/5G Core. He loves working in constrained environments.
He was the Organizer & Host of CppIndiaCon, since inception. His dream came true when he hosted the AMA with Bjarne Stroustrup!
He is the Core Organizer at CppIndia, India's C++ User Group, the most active C++ user group.
He has presented at CppCon 2020 & CppCon 2021, CppIndiaCon 2021 & CppIndiaCon 2022
__

Videos Streamed, Edited, and YouTube Channel Managed by Digital Medium: http://online.digital-medium.co.uk

#cppcon.digital-medium.co.uk/tag/cppcon/">cppcon #cppcon.digital-medium.co.uk/tag/programming/">programming #cpp

Filed under: UncategorizedTagged with: , , , , , ,