☟☟ 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:
Why are the accessors constexpr? Isn't the fact that they are inline enough for the compiler?
It actually IS possible to make access of the array member undefined behavior. Just state in the documentation that the name of the member is unspecified and its use undefined 😉
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.
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.
Why isn't it implemented in the standard library with the _M_values declared private, if it is illegal to access?
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.
Can I assume the memory layout of std::array is the same as a c array? I couldn't find anything in the standard, but it would seem to make sense.
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.
Very informative. Thank you.
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.
3:04 isn't right include for size_t in <cstddef> ?
What compiler parameter shows the uninitialized error at 3:20? I'm not getting it :/
oh god listening to this while I try to write my first ever Python program was a mistake.
Would've been neat to touch on the specialization stuff for 0-lengthed arrays that are necessary without a compiler extension
What IDE/page is at 07:42 when looking at GCC code? thanks
It would be nice to see something like a same_for_const keyword/modifier that would just make the const version of functions for you.
all the boilerplate required is just irritating. wish there was some shortcut for all those trivial overloads
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.
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: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.
The Waffle House Has Found Its New Host
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.
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.
Did not know you can tuple-ize that easy.
Thanks!
HAHA I broke your code 😀
why the array data element is not private?
For those who want to a similar content of """implementing the basics components std from scratch""" and C++ basics/internals/history the Alex Stepanov lectures at A9 videos are a must.
https://www.youtube.com/@A9Videos/playlists
Would like to see more on Structure binding in C++ (8:47)
Good stuff, Thanks!
Just as a small note, depending on the allocator used, std::vector can also be stack allocated.
<cstddef> might be a more proper place to find std::size_t
No constructor. So I can not "void f( array<int,2> i ); f( {1,2} );" Annoying.