CppCon 2016: Michał Dominiak “Variadic expansion in examples"

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ต.ค. 2024
  • CppCon.org
    -
    Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/cpp...
    -
    Templates - and variadic templates - are an important aspect of writing a successful library in C++; libraries that can deal with custom types the user creates greatly eases their use. Variadic templates specifically are still a new, relatively unknown and at the same time quite a buggy (in the sense of bugs in their implementations) tool, but nevertheless, they offer much easier ways of creating truly generic types and functions.
    This talk will focus slightly less on variadic templates in general; the common pitfalls will be discussed, but more attention will be given to the tool of parameter pack expansion and all the contexts where it can be used, especially as a code generation tool.
    The talk will start mostly from scratch, assuming the audience's general knowledge about templates. It'll introduce the idea of variadic templates and general syntax and typical techniques for their use. Next, it will head into the (mostly) unknown and buggy lands of the interesting uses of variadic packs, like unpacking a tuple into a function call using `std::integer_sequence`, the use of empty packs for a slightly easier way to work with `enable_if`. The final examples will explain the way of invoking an expression per every argument in a pack, and dispatch to appropriate version of code for each of the argument types based on runtime values, which will be used to more easily create variant visitors.
    -
    Michał Dominiak
    Software Engineer, Nokia Networks
    Bachelor of Engineering in Computer Science, studied at Faculty of Electronics at Wrocław University of Technology. Loves metaprogramming and doing as much as possible during compile time, instead of wasting precious cycles at runtime.
    -
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    *-----*
    Register Now For CppCon 2022: cppcon.org/reg...
    *-----*

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

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

    tuple's pronunciation:
    th-cam.com/video/JhgWFYfdIho/w-d-xo.htmlm34s
    :)

  • @eugnsp
    @eugnsp 3 ปีที่แล้ว

    The standard pre-fold-expressions trick was: int dummy[]{0, ((void)func(args), 0)...}; (void)dummy;

  • @ExCyberino
    @ExCyberino 3 ปีที่แล้ว

    there's one caveet with this technique 10:00

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

      th-cam.com/video/Os5YLB5D2BU/w-d-xo.html

  • @michaszczypek5660
    @michaszczypek5660 7 ปีที่แล้ว

    T-shirt