Cute C++ Tricks, Part 2.5 of N - Code You Should Learn From & Never Write - Daisy Hollman - CppCon22

Поділитися
Вставка
  • Опубліковано 25 сер 2024

КОМЕНТАРІ • 20

  • @Qazqi
    @Qazqi Рік тому +2

    In my own experience, the one scenario where I've desired to have function template partial specialization was when the template parameter is used only as a template parameter and not as a function parameter. Overloads don't help at all for that, but you can of course work around it via a `wrapper` function parameter where `wrapper` is functionally identical to `std::type_identity`.

  • @embeddor3023
    @embeddor3023 Рік тому +8

    Can we please add the overload set pattern into the standard? It's very useful for variant visitation and it doesn't make any sense to keep writing this manually everytime we need this ...

    • @Roibarkan
      @Roibarkan Рік тому +1

      I believe it's discussed in the committee - p1772 (and p0051).

  • @Qazqi
    @Qazqi Рік тому +1

    The trick to replace a primary template is 100% UB because you can't just put stuff in std willy-nilly, but it's incredible that in practice, you can now bring C++ back to the old JS days of just replacing something you don't like. You can't have constraints on non-template functions (yet? didn't follow whether it was delayed or denied), but that would've gotten us pretty damn close, not that the standard library has much non-template code anyway.

  • @Bolpat
    @Bolpat Рік тому

    44:00 Note that for user-defined char sequence literals, you also get separator and decimal point characters. For that reason, you cannot simply subtract '0' and add.

  • @Bolpat
    @Bolpat Рік тому

    10:20 Actually, there’s four ways to express constrained template parameters because you can put a requires clause behind the template parameter list and behind the function parameter list. The second version exists so you can refer to parameters in the constraints (e.g. decltype(param)), but to be honest, I don’t really understand where requires behind the template parameter list really shine.

  • @Bolpat
    @Bolpat Рік тому

    Hex floating point literals are nuts: static_assert(0xAB.Cp1 == 0x55.Ep2); That is because the exponent is 2-based, not 16-based: static_assert(0xAB.Cp0 == 0xA.BCp4); Can you guess what 0x1.4p3 is?

  • @JohnWasinger
    @JohnWasinger Рік тому

    Nice plug for Python there. 49:30

  • @lukasz2345
    @lukasz2345 Рік тому +1

    Where I can find that slides?

    • @Roibarkan
      @Roibarkan Рік тому +2

      The link is on the bottom left of every slide, ends with cppcon-2022 (sorry for not putting a link, youtube won’t allow it)

  • @6eeykwr2
    @6eeykwr2 Рік тому

    Great talk as always Daisy

  • @Roibarkan
    @Roibarkan Рік тому +1

    19:16 “requires expression”, I believe

  • @WndSks
    @WndSks Рік тому +3

    Code font is too small as usual on these talks.

    • @KulaGGin
      @KulaGGin Рік тому +1

      It's just fine on my monitor. -Get a bigger monitor.- Just kidding. The player should allow zooming in and out. Well, if you really want to, PotPlayer allows to open YT videos and easily zoom in and out, and move the focused part to where you want it.

  • @PaulMetalhero
    @PaulMetalhero Рік тому

    Why do you write class instead of typename?

    • @eLBehmo
      @eLBehmo Рік тому +1

      Slide code / it's shorter

  • @michaelzomsuv3631
    @michaelzomsuv3631 Рік тому +2

    Is there an equivalent of this talk but for C?

    • @AstuteJoe
      @AstuteJoe Рік тому

      Yeaaaaaaaaah, this template stuff also doesn't quite interests me, but something digging deep into pointers, SIMD instructions, memory management, etc... would be awesome! Arena allocators? There's some cool trickery when replacing free and malloc

  • @__hannibaalbarca__
    @__hannibaalbarca__ Рік тому +1

    May be my word will be very harmful; i should tell it:
    These day c++ standard-er need to learn deep concepts of mathematics logics and predicate calculus, topology and algebraic topology;
    The old way of concept is more better than key word concepts and should be replaced by TheCondition ;
    Because Concepts should build a fonction or Templates and under the template we write what the conditions should be for the parameter ; the concepts gave a general rule inside class or function {like return type, errors, max_memory or type of execution ……….} . Am y right.