☟☟ Important conference, book and swag info in description ☟☟

T-SHIRTS AVAILABLE!

► The best C++ T-Shirts anywhere!

WANT MORE JASON?

► My Training Classes:
► Follow me on twitter:

SUPPORT THE CHANNEL

► Patreon:
► Github Sponsors:
► Paypal Donation:

GET INVOLVED

► Video Idea List:

JASON’S BOOKS

► C++ Best Practices
Amazon Paperback:
Leanpub Ebook:

JASON’S PUZZLE BOOKS

► Object Lifetime Puzzlers Book 1
Amazon Paperback:
Leanpub Ebook:

► Object Lifetime Puzzlers Book 2
Amazon Paperback:
Leanpub Ebook:

► Object Lifetime Puzzlers Book 3
Leanpub Ebook:

► Copy and Reference Puzzlers Book 1
Amazon Paperback:
Leanpub Ebook:

► Copy and Reference Puzzlers Book 2
Amazon Paperback:
Leanpub Ebook:

► Copy and Reference Puzzlers Book 3
Leanpub Ebook:

► OpCode Puzzlers Book 1
Amazon Paperback:
Leanpub Ebook:

RECOMMENDED BOOKS

► Bjarne Stroustrup’s A Tour of C++ (now with C++20/23!):

AWESOME PROJECTS

► The C++ Starter Project – Gets you started with Best Practices Quickly –
► C++ Best Practices Forkable Coding Standards –

O’Reilly VIDEOS

► Inheritance and Polymorphism in C++ –
► Learning C++ Best Practices –

✅ Camiseta De Futbol Baratas Player vs Fan | camisetasfutboleses

🛒 Cómprala aquí: https://www.pidecamisetas.com/

📸 Siguenos en Instagram: https://www.instagram.com/msy_es/

📲 WhatsApp: +86 166 5930 6369

👏 ¡Muchas gracias por ver el vídeo! 👏

🔴 LIKE & SUBSCRIBE 🔴

🔴 Keywords:Camisetas VILLARREAL

__

🏷️ TAGS:
CAMISETA Real Madrid 22/23
camisetasfutboleses
camisetasfutboleses.com
CAMISETAS FUTBOL SPAIN
CAMISETAS DE FUTBOL
CAMISETAS FUTBOL Baratas
CAMISETAS DE FUTBOL 2020
CAMISETAS DE FUTBOL 2021
CAMISETAS DE FUTBOL 2022
CAMISETAS FUTBOL EQUIPOS
CAMISETAS FUTBOL SELECCIONES
CAMISETAS DE FUTBOL BARATAS
MEJORES CAMISETAS DE FUTBOL
EQUIPACIONES FUTBOL
EQUIPACIONES DE FUTBOL

Otros sitios web de nuestra empresa para que los visite:

31 comentarios en «C++ Weekly – Ep 359 – std::array's Implementation Secret (That You Can't Use!)»
  1. Video starts off by denigrating C arrays (fair enough) then proceeds to write the same function in 8 different incantations to satisfy the C++ compiler. Of course there are issues with C array/pointer duality, there is talk of fat pointer primitives in C23 but I don't think anyone knows for sure. It's not that painful to roll your own range for loop enabled array in C99 (with a little less syntactic sugar, if the preprocessor offends you). Love the videos JT but to me it's unfortunate so much effort is wasted coping with the accidental complexity of C++. I won't hold my breath for C weekly, but I can dream.

  2. Maybe nitpicky but writing a c array like 'S s[5]' DOES initialize the array. It always calls the default constructor of every element in the array. It just happens to be that the default constructor of int isn't doing anything.

  3. Just a quick reminder that `std::size_t` is defined in <cstddef> along with its signed counterpart `std::ptrdiff_t`. The <cstdint> header is only for fixed integer types like `std::int8_t`, `std::uint32_t`, etc.

    Also you should include <fmt/core.h> in order to use `fmt::print` and not <fmt/format.h> header.

  4. People have been trying to use string literals as template arguments and failed. I just use std::to_array to convert string literal to std::array and use the std::array as template argument. You have to ignore the terminating null, but I use std::make_index_sequence and some template magic to remove the null from the std::array.

  5. One thing that infuriates me about std::array is that unlike std::vector "capacity" and "size" are the same value. Thus if you have situations like this:

    std::array<double, 10'000'000> arr;
    std::fill(arr.begin(), arr.end(), 0.0);

    //Imagine some type of user input like a stream from a signal of some kind here.
    arr[0] = 1.1;
    arr[1] = 45767.98;
    arr[2] = 2.33;
    //…
    arr[100'000] = 12.97;

    //We've got an array of 10 million elements but have only used 100 thousand.

    for(size_t i = 0uz; i < arr.size(); ++i)
    {
    arr[i] = std::sin(arr[i]) * std::tan(arr[i]) / 2.0;
    //9.9 Mil unnecessary calculations that could fill the unused part of our array with a bunch of NaN and -Nan or result in a ton of DIVIDE_BY_ZERO exceptions being generated and thrown.
    }

    In order to fix this I usually wrap std::array in a struct like this:

    template<typename T, std::size_t Size>
    struct fixed_array{
    std::array<T, Size> data;
    std::size_t in_use_size = 0uz; //TO-DO Increment this when a new value is added, decrement when a value is removed ONLY from the end
    };

    Which usually necessitates adding operator overloads and wrapper functions for everything std::array does so that the code isn't confusing or even more infuriating to use.

    This issue makes using std::array a lot of work. I can't wait for boost's static_vector to get into the standard so we can have a stack allocated array with different variables for size and capacity.

  6. Nice peek under the hood, should be convincing that using std::array instead of C array won't necessarily add much or any runtime or storage cost in normal usage (just a little bit of compilation time; and at() can throw but use -fno-exceptions if you are worried about that, or don't make out of bounds accesses!) but adds a better and safer interface.

  7. 6:19 I started using a single underscore `_` to define a variable that the user really should not care about. I imagine I'd probably do `_0`, `_1`, `_2` if there are multiple variables (but in that scenario I would say there's a code smell somewhere)

    I started this when I noticed CLion's parameter name hints ignored underscores, and the existence of the hint made the code look ugly in the IDE, so I went with `_` when it was incredibly obvious. Perhaps `_` in a user array implementation makes sense

  8. 8:05 since constexpr is implicitly inline, size() == 0 turns into _Nm == 0 at compile time, so this is just for better readability. For someone who just jumped into the code, size() is pretty self-explanatory but _Nm requires some digging.

  9. Wouldn't it be a good idea, if you start another channel called "Rust Weekly" where you basically do go over the same topics as here but for Rust. I think this would be greatly beneficial for your audience.

  10. What a wonderful example of why deducing this was standardized. It can't actually be used for `std::array`, mostly for compatibility concerns, but any third party container will absolutely want to deduce this instead of writing four overloads for every member function.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *