From Templates to Concepts: Metaprogramming in C++ - Alex Dathskovsky - CppNow 2023

Sdílet
Vložit
  • čas přidán 2. 06. 2024
  • www.cppnow.org​
    / cppnow
    ---
    From Templates to Concepts: Metaprogramming in C++ - Alex Dathskovsky - CppNow 2023
    Slides: github.com/boostcon
    ---
    Metaprogramming has been a powerful feature of C++ since its introduction in C++98. However, as the language has evolved, the tools and techniques for metaprogramming have also improved, making the code simpler, more expressive, and easier to read. In this talk, we will explore the history of metaprogramming in C++ and how the use of development has become clearer and more elegant with each new version of the standard. We will start by discussing the metaprogramming techniques used in C++11-17. We will dive into the new features in C++20, such as concepts, that make metaprogramming more powerful, expressive, and easy to read. To demonstrate this, we will implement a metaprogramming example using C++11-17, and then show how the same example can be written in a much cleaner and more elegant way using C++20 concepts. This talk is aimed at C++ developers who want to improve their metaprogramming skills and take their code to the modern age.
    ---
    Alex Dathskovsky
    Alex has over 16 years of software development experience, working on systems, low-level generic tools, and high-level applications. Alex has worked as an integration/software developer at Elbit, senior software developer at Rafael, technical leader at Axxana, software manager at Abbott Israel, and now a group manager a technical manager at Speedata.io, an exciting startup that will change big data and analytics as we know them. In his current job, Alex is developing a new CPU/APU system working with C++20, massive metaprogramming, and the development of LLVM to create the next Big Thing for Big Data.
    Alex is a C++ expert with a strong experience in template meta-programming. Alex also teaches a course about the new features of modern C++, trying to motivate companies to move to the latest standards.
    ---
    Video Sponsors: think-cell and Bloomberg Engineering
    Audience Audio Sponsors: Innoplex and Maryland Research Institute
    ---
    Videos Filmed & Edited By Bash Films: bashfilms.com/
    CZcams Channel Managed & Optimized By Digital Medium Ltd: events.digital-medium.co.uk
    ---
    CppNow 2024
    www.cppnow.org​
    / cppnow
    ---
    #boost #cpp #softwaredevelopment
  • Věda a technologie

Komentáře • 7

  • @alexschiffer6237
    @alexschiffer6237 Před 11 měsíci +3

    Knowing templates well is job security

  • @scotthinton4610
    @scotthinton4610 Před 5 měsíci

    Great talk! I feel a bit more confident in understanding some of the TMP I've come across after watching.

  • @yanushkowalsky1402
    @yanushkowalsky1402 Před 10 měsíci

    beautiful

  • @simonfarre4907
    @simonfarre4907 Před 11 měsíci +2

    I think what the first comment was about (about overloading) is that if X has two `add`, one which returns float, and one that returns int (with different parameters), you would have to write
    static_assert(std::is_same_v) for it to work - because how would it otherwise be able to tell *which* add you want? This is the problem with overload sets.
    In other words, if the overloaded methods return different types, you're out of luck.

    • @toddfulton2280
      @toddfulton2280 Před 10 měsíci

      Yeah, concepts are basically syntactic sugar over sfinae, they help in cases where you need to disambiguate on overload resolution, but other than that, they don't actually solve anything. Specifically, they dont enforce constraint in an impl, ie your still in the land of ducktyping which is generally bad for scalability, hence all the tmp and traits and concepts, same reason people move to typescript. If we had typed generics, we could get a lot features for "free" from the type system, like automatic type erasure given a typeclass, carbon is looking into that last i checked. So templates being untyped was supposed to increase dev productivity, but it does the opposite as u scale up.

  • @toddfulton2280
    @toddfulton2280 Před 11 měsíci +1

    What do I think of when I hear "C++ templates"? Broken parametric polymorphism. Concepts *kind-of* patch that, but imho, suffer from the implementation of the concept being totally disjoint from the concept, e.g. you can't say "I am implementing concept `C` for type `T` here." like you could to for type classes or type traits in other languages (e.g. `instance Eq T where...`). Another problem is that if a concept depends on a function or member function being defined for a type, you run into the same issue where you are essentially globally reserving a name like with std::swap and cpos as customization points. That is, a type could define a member function `F` that passes concept `C`, but doesn't actually implement `C` semantically, this is the "disjoint implementation" problem. I think concepts in c++ would be more useful as a mechanism for validating contracts and semantics at compile time (if possible) for type classes.

  • @userrand4900
    @userrand4900 Před 10 měsíci

    The author should correct the statement made here czcams.com/video/x6_o-jz_Q-8/video.html. He mentions an integral comparison is made, which is false. E.g. by that argument foo(1, 1.2) should return true as well which it does not.