Understanding The constexpr 2-Step - Jason Turner - C++ on Sea 2024

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • cpponsea.uk​
    ---
    Understanding The constexpr 2-Step - Jason Turner - C++ on Sea 2024
    ---
    C++20 enabled both std::vector and std::string for constexpr usage. However, this simple case does not compile:
    constexpr std::vector<int>data{1,2,3,4,5};
    If we cannot create constexpr strings and vectors, then what good are they for constexpr use?
    This talk will cover the "constexpr two-step." A method of getting data of unknown size generated at compile time into the runtime world while minimizing binary sizes in the process.
    ---
    Slides: github.com/phi...
    Sponsored by Bloomberg: www.bloomberg....
    Sponsored By think-cell: www.think-cell...
    ---
    Jason Turner
    Jason has 2 decades of C++ experience and is a regular conference speaker, developer, and trainer. He has been publishing weekly C++ videos on his UA-cam channel, C++ Weekly, since 2016.
    ---
    C++ on Sea is the international C++ conference taking place by the sea, in the UK. Our venue is in Folkestone, Kent, near the entrance to the channel tunnel with stunning views across the English Channel.
    Annual C++ On Sea Conference - www.cpponsea.uk
    / cpponsea
    x.com/cpponsea
    www.facebook.c...
    / cpponsea
    vmst.io/@cpponsea
    ---
    UA-cam Videos Filmed, Edited & Optimised by Digital Medium: events.digital...
    ---
    #cpp #cplusplus #cppprogramming #programming #cpponsea

КОМЕНТАРІ • 5

  • @scion911
    @scion911 7 днів тому

    This is a type of problem I reached while doing things in constexpr, essentially you have to have MAX_LIMITS for oversized array, have a computation run once where you basically compute the size of the result (usually just computing the entire thing) then discard every result and just return the size. Then take the size as a constexpr then again run the computation in an appropriate sized array not to blow up the memory. This caused massive issues for compile times. I reached the same copy twice method for compile-time later, but unfortunately my usecase deemed c++ constexpr interpreter thing too slow.
    This led me to switch my library to zig comptime. Which has much better semantics than C++ unfortunately for compile time stuff. Not to mention it doesn't color functions as constexpr, it just runs it if possible to run it in comptime.

  • @kimhyunpil
    @kimhyunpil 11 днів тому

    If you're looking for code that generates a string at compile time, you definitely need to watch this lecture.👍

    • @SkegAudio
      @SkegAudio 6 днів тому

      just got started with cpp. What's the significance of this feature?