STL sequence containers (and friends) in modern C++

preview_player
Показать описание
Here we start talking about the STL (Standard Template Library) containers and some utility types that make our life easier. We also speak a bit about how to use all of them and what caveats we should be aware of.

We cover sequence containers:
- std::array
- std::vector

And some other utility containers:
- std::pair
- std::string

*Please support this course!*
- Get a FREE Audible trial here:

*Stuff I'm using*

Contents:
00:00 Intro
00:22 Disclaimer
00:55 Symbols used on slides
01:27 Introducing STL
02:13 A couple of words about containers in general
02:29 std::pair
04:54 Sequence containers
05:18 std::array
06:49 Access elements of std::array
08:27 UB when accessing elements
09:06 Small example with std::array
09:25 std::vector
10:59 Modify size of std::vector
12:51 Optimize vector resizing
13:54 Example of reserve()
14:28 Example of using std::vector
15:54 std::string
17:06 Example with std::string
18:14 Convert numbers to/from strings
19:17 Conversion examples
19:56 A couple of caveats
22:30 Aggregate initialisation
23:47 Other sequence containers
24:29 Outro

Corrections:
18:16 The string passed to std::stoi must start with a number. Otherwise, an error is thrown. So the string should be smth like "42 is a number" instead.
13:23 The end condition of the loop should use **number_of_iterations** and not **kIterNum**
Рекомендации по теме
Комментарии
Автор

Thanks Igor. Appreciate the extra mile of explaining the different C++ version implementations.

WWraven
Автор

The treatment of different versions of c++ and slight differences between each std are unique and std practices right from the beginning
That really stands out

mohab.ahmed.
Автор

Very clear. I am using your lessons to complete the homneworks from the 2020 c++ course from Bonn Uni with professors Stachniss and Vizzo. Honestly without your lectures I would be lost. Huge thanks!

Elclaapo
Автор

I am enjoying so much this course playlist. Thanks!!!

leonardodosanjoschaves
Автор

This will be one of the best C++ series, among of course The Cherno one!

graffioh
Автор

I keep making these silly mistakes! 😅
- 18:16 - *std::stoi* will throw an error if run as shown. The number has to be at the start of the provided string instead, e.g. "42 is a number". The slides are already changed to reflect this.
- 13:23 The end condition of the loop should use *number_of_iterations* and not *kIterNum*

As always, let's chat about what you guys like and what you dislike! In the end, this course is for you, so please feel absolutely free to share your thoughts and tell your friends about it! 🙃

CodeForYourself
Автор

Igor, thanks for this video!

Could you clarify in what cases, in practice, we will use Pair?

More comments, more videos :)

tamtanart
Автор

🤯 wow, wouldn’t guess that this suppose to work: const auto [a, b, c] = arr

olgavysotska
Автор

thank you for this series. i have a request. as Conan is one of the widely used C++ package managers, it would be nice to have a tutorial on how to setup a repository where the dependencies are handled via Conan. :)

masaaldosey
Автор

Thanks for the great video!! I have a comment though on int another_number{std::stoi("the number is 42")}; on your lecture. It will throw an error instead of ignoring the text. It seems to work only when the number precedes the text. For example, int another_number{std::stoi("42 is the number")}; will ignore the text and print 42 (compiled with c++17). Please let me know if I am wrong on this.

chrislee
Автор

What is the difference between *std::vector<int> a(number_of_elements);* and *std::vector<int> a; ?
Is it like we allocate memory that we not actually using right now in the first case?
While in the second case, compiler will know about amount, and will allocate when we exaclty will need it?

Anton-vuou
Автор

I started this course with some basic knowledge about C and with this lesson I have realised how different these languages are.
Why C++ STL defines a different string type? What is wrong with the classical C string?

albertotejadamolina
Автор

Maybe highlight the line of code your are explaining it's hard to some time know which line you are explaining

mukto
welcome to shbcf.ru