CppCon 2018: Andrew Sutton “Concepts in 60: Everything you need to know and nothing you don't”

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 มิ.ย. 2024
  • CppCon.org
    -
    Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2018
    -
    The Concepts TS -- the ISO-published Technical Specification for
    constrained templates -- was merged into the C++20 Working Paper in
    2016. This is a big deal for C++. We've been missing this kind of
    language feature for nearly 30 years. Well... now that we have it,
    it's probably a good idea to know what it's for and how to use it.
    This talk covers basic topics of generic programming using concepts.
    I will talk about using concepts to write constrained templates,
    overloading constrained functions (why, when, and how), and how to
    define good concepts (which is a bit trickier than you might imagine).
    I will also discuss some of the changes to the syntax and semantics
    of language features in the Concepts TS when it was merged into
    the Working Paper for C++20.
    -
    Andrew Sutton, University of Akron
    Andrew Sutton is an Assistant Professor at the University of Akron where
    he teaches, hacks on compilers and other interesting problems, and writes the
    occasional research papers. Dr. Sutton is a member of the C++ Standards Committee,
    the editor of the Concepts Technical Specification, and implemented concepts in
    GCC. He has spent the past year working on language support for software-defined
    networking and on C++ support for compile-time programming, reflection, and
    metaclasses as an extension of the Clang C++ Compiler.
    -
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    *-----*
    Register Now For CppCon 2022: cppcon.org/registration/
    *-----*

ความคิดเห็น • 21

  • @AdamStallard
    @AdamStallard 4 ปีที่แล้ว +19

    "Your concrete algorithms are just instances of templates you haven't written yet" - going to use this line lol

  • @OperationDarkside
    @OperationDarkside 5 ปีที่แล้ว +5

    Nice talk. I like how this helps with compiletime class composition, by essentially enableing template interfaces.

  • @kamalabuhenamostafa
    @kamalabuhenamostafa 5 ปีที่แล้ว +1

    nice presentation

  • @RodriTheMighty
    @RodriTheMighty 2 ปีที่แล้ว +2

    Wait, at 1:01:50 I know that voice. That has to be lefticus! :D

  • @zhaoli2984
    @zhaoli2984 5 ปีที่แล้ว +3

    nice talk, plus the speaker is humorous

  • @EladM8a
    @EladM8a 4 ปีที่แล้ว +1

    8:13 I actually didn't understand what all_ordered checks in the case of int** pointers. on what scenario can this fail?

    • @alextern2146
      @alextern2146 3 ปีที่แล้ว +1

      It may fail, because pointers that doesn't belong to the same array or the same object (and a couple of other interesting clauses) shouldn't be compared with relation operators, the result is unspecified. You can look at § 5.9 of C++ standard for more details. Generally all_ordered function checks that only one of relation operators matches for given addresses.

  • @loomismeister
    @loomismeister 5 ปีที่แล้ว +1

    Isnt existing generic code using templates already functioning as a requires(auto) concept. That you will only be able to compile things which your given type can satisfy seems like an implicit minimal concept.

    • @Quuxplusone
      @Quuxplusone 5 ปีที่แล้ว

      What you're talking about is "template concept Auto = true;". When Andrew talks about "requires(auto)", he's talking about the construct described in this Q&A over here: th-cam.com/video/CXn02MPkn8Y/w-d-xo.htmlm00s

  • @USGrant21st
    @USGrant21st ปีที่แล้ว

    1:06:50 -- this differences in behavior of concept and type traits can cause very subtle errors in overloaded functions. Variadic concepts become especially problematic.

  • @Voy2378
    @Voy2378 5 ปีที่แล้ว +5

    It is kind of fitting that a person that could not implement a language feature on time or you know actually in a good way needs 115 slides for introduction to that feature.

    • @RodriTheMighty
      @RodriTheMighty 2 ปีที่แล้ว

      wat? Is that supposed to be derogatory?

  • @User-cv4ee
    @User-cv4ee 3 ปีที่แล้ว

    Off-topic, but what does [[assert axiom...]] do? I tried googling it but it’s giving random search results.

    • @not_ever
      @not_ever 2 ปีที่แล้ว

      If you Google cpp 20 contracts you should have better luck finding the information you require. Contracts were dropped from c++ 20 though so it's not something you will be using anytime soon I guess.

    • @brewtaldeafmedal1262
      @brewtaldeafmedal1262 2 ปีที่แล้ว

      C++20 contracts that were voted out of C++20

  • @xplorethings
    @xplorethings 5 ปีที่แล้ว +9

    I can't help but find the bracket syntax for concepts to be an utterly poor choice. It's unreadable as hell when combined with template features, for once we had a chance to make a new feature easy to read, but std committee once again proved itself to only hurt C++.

    • @parzer0
      @parzer0 5 ปีที่แล้ว +2

      they hurt themselves because they have to deal with this type of know it all asshole talking like he invented breathing and all the standard library header files

  • @Voy2378
    @Voy2378 5 ปีที่แล้ว +1

    at 45:03 he makes a big mistake... "you should measure" Except results depend on T, so it is impossible to measure. Unless you want to constexpr if based on T... and that is a lot more work.

  • @morthim
    @morthim 5 ปีที่แล้ว +7

    "what is a concept? a named predicate expressing requirements on template arguments"
    so it is a template. would have been nice 15 minutes earlier.