Ask coding questions

← Back to all posts
Standard Template Library (C++)
h
DynamicSquid (824)

Hey guys! Currently I'm making a tutorial on STL containers (std::vector, std::list, std::etc.), and I think I might publish it around next week.

So does anyone have any suggestions of things to include? I'm definitely going to be going over the basic STL containers, along with some useful tips and algorithms. But is there anything different you guys will want to see?

Please let me know in the comments. Thanks, and see you next week!

UPDATE: It's released!

Commentshotnewtop
theangryepicbanana (1507)

You should try to include cool things like std::map, std::initializer_list, std::tuple, and std::function :)

DynamicSquid (824)

@theangryepicbanana For sure! I'll include maps, lists, sets, and all those. I already replied to @Highwayman on this, but for std::tuples, I know enough about it's basics, but I don't know all the advanced stuff you can do with those.

DynamicSquid (824)

@theangryepicbanana Also I feel like std::function could be a tutorial of its own... What do you think?

Highwayman (1257)

@DynamicSquid it’s not necessarily used a lot(tuple), but it is cool...
@theangryepicbanana oo std::function! nice one!

Oh my. I’m geeking out over the stl.
Oh no.

nt998302 (132)

@Highwayman It throws me whenever my teacher assigns me something and they use "->". I'm just like, "POINTER!!!!"...

Highwayman (1257)

@nt998302 Do you geek out specifically over pointers?

Highwayman (1257)

@nt998302 pointers are pretty sick. :P I still don’t like smart pointer though I’m really behind on learning those :/

ipastrano (196)

@Highwayman I looove pointers, as for the smart pointers, i only know unique_ptr as for smart ones. I dont really see the point of smart pointers, the delete function is there for a reason.

DynamicSquid (824)

@ipastrano Wait, there's different types of smart pointers? Wut?

Anyway, some people criticize C++ for having no automatic garbage collection. But that's why we have smart pointers. Right? Or are they just too much of a hassle that delete is just better?

Highwayman (1257)

@ipastrano

I looove pointers

it’s funny, cause all us C++ programmers love pointers, and the only real reason that I ever really read about for ppl not to like C++ is because of pointers.. lol

Anyways Idk bout that. The point is to reduce the likelihood of bugs like memory leaks and stuff, yes? I guess the reason I personally don’t like them is more because I’m really nervous all the time about using STL containers, because I’m never entirely sure how they will act in certain vital situations. I guess I’m just too lazy to look it up?

DynamicSquid (824)

@Highwayman That is true. C++ is one of the few languages with pointers. So I guess we kinda just got use to it lol

DynamicSquid (824)

@Highwayman It funny how the first language you learn acts as a base, and all the other language that are different from the first one are weird. Like have you seen Java's classes and object syntax? It's ridiculous!

Highwayman (1257)

@DynamicSquid ya know, I feel like that’s just java. Like java is just not.. I can’t even describe my resistance to learning java.

ipastrano (196)

@DynamicSquid there's `weak_ptr and another one that i forgot the name of. they are a bit of a hassle, delete is just easier, but i guess it can be tedious in a long program with a lot of dynamically allocated space, and the memory leaks can add up. But i still like delete bc im careful.

DynamicSquid (824)

@Highwayman Word. Like the first time I saw Java's classes and objects syntax, I gave up immediately. Like wdym you have to specify the visibility for each individual attribute??? And they don't even have private or protected inheritance, let alone multiple inheritance

Highwayman (1257)

@DynamicSquid honestly! Why! Like tf man.

Highwayman (1257)

@DynamicSquid yeah :p
We are just going off on the randomest things rn lol

DynamicSquid (824)

@Highwayman yeah lol. As long as we're talking about C++, that's fine with me. I never have any conversations about C++, let alone programming anywhere but here

Highwayman (1257)

@DynamicSquid I’ve had conversations about programming with my friends before outside of repl.it, but they never seem to be meaningful(programming wise I mean) in any way lol. This really is just the best place for programmers. It really is.

ipastrano (196)

Make sure to talk about iterators, they are really useful. OwO i need a refresh on those, can't wait to see the tutorial!

DynamicSquid (824)

@ipastrano Yup! Don't worry about it!

Highwayman (1257)

UwU yay!
Things I’d really like to see in order of preference...
1) std::multimap // because I am so confused by how it’s supposed to / does work
2) std::tuple // because it’s amazing
3) std::any // because it’s amazing

DynamicSquid (824)

@Highwayman Oh yeah for sure, I'll be covering maps, multimaps, unordered maps, and all those. For std::tuple, I'm not really an expert on that, but I know enough about the basics, so I'll try to fit that in as well. And for std::any, I'm not really an expert on any of the new C++17 features, as I'm learning C++14, but I'll try my best to include that as well. Thanks for the suggestions!

nt998302 (132)

@Highwayman Eyyyy. C++ Squad! I feel like no one on repl codes C++ :(

DynamicSquid (824)

@nt998302 That is so true. The thing with C++ is that you have to be really good at it to make something cool. With other languages such as Python or HTML, even knowing the basics you can still make a game...

nt998302 (132)

For sure keep vectors, lists. Introduce stream writing and list sorting. If you know how, which I bet you do, go over dynamic casting and smart pointers. Good Luck!

DynamicSquid (824)

@nt998302 Thanks for your reply! I'm going to cover all the main STL containers, lists, maps, deques, sets and more. But don't you think that stream writing, dynamic casting, and smart pointers are for another tutorial? I kinda just want to stick with lists for this tutorial, otherwise it'll be a mess to write

nt998302 (132)

@DynamicSquid I guess you can create a separate tutorial for that stuff as it's a little more complex...

DynamicSquid (824)

@nt998302 Yeah, I probably will. I also have to learn what smart pointers actually are before I start teaching it lol

nt998302 (132)

@DynamicSquid xD, I don't know much about them either. I used Unreal for a while, but the C++ in it was too difficult for what I wanted to do, so I switched to Unity C# and now I'm flowing

DynamicSquid (824)

@nt998302 Oh that's cool! I actually tried learning Unreal for a couple of weeks, and I really liked making abandoned structures and forests and those "nature" scenes. But I totally agree, making games in Unreal using C++ is a little too complicated. However I really want to learn Unity and C# like you did, but I also kinda want to "finish" learning C++ first...

DynamicSquid (824)

Oh, hey guys, quick questions. So I'm writing the tutorial on Google Docs right now, and the section about vectors is already 1000 words long. And I still have to talk about lists, sets, mutisets, maps, and more! Should I post each section separately? Or will a giant long tutorial do?

Highwayman (1257)

@DynamicSquid Personally I love giant tutorials, but that just might be me. 🤷‍♂️ I’d say just do what you feel is best. It is your tutorial after all. :)