Writing an ITERATOR in C++

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.พ. 2025
  • Data is everywhere! Enhance your career and acquire new skills by taking a course on DataCamp! Click here to take the first chapter of any course for FREE: bit.ly/2ZrYE6O (you’ll be supporting my channel too!)
    Patreon ► / thecherno
    Instagram ► / thecherno
    Twitter ► / thecherno
    Discord ► thecherno.com/...
    Series Playlist ► thecherno.com/cpp
    This video is sponsored by DataCamp.

ความคิดเห็น • 167

  • @TheCherno
    @TheCherno  4 ปีที่แล้ว +37

    Thanks for watching! ❤️ Data is everywhere! Enhance your career and acquire new skills by taking a course on DataCamp! Click here to take the first chapter of any course for FREE: bit.ly/2ZrYE6O (you’ll be supporting my channel too!)

    • @phoenixjauregui5508
      @phoenixjauregui5508 4 ปีที่แล้ว +2

      I first learned programming through DataCamp. Great sponsor!

  • @muhammedyasinhanyasar539
    @muhammedyasinhanyasar539 4 ปีที่แล้ว +215

    When I learn all C++17 features, C++34 going to be released.

    • @lapatatadelplato6520
      @lapatatadelplato6520 2 ปีที่แล้ว +3

      I don’t understand all that your saying, just what I can understand

    • @LOL-cp6js
      @LOL-cp6js ปีที่แล้ว +1

      First time?🌚😂

    • @mihevoct5624
      @mihevoct5624 ปีที่แล้ว

      Same

    • @Delllatitude7490
      @Delllatitude7490 5 หลายเดือนก่อน +1

      Don't have to worry, there isn't going to be a C++34, it will be C++35 😂

  • @lainproliant
    @lainproliant 4 ปีที่แล้ว +72

    I'm a fairly seasoned C++ developer, having been using it since 2000. I enjoy your videos simply because I like to know how things are being taught today, and I like having a window into the game development world. Watching other people write and talk about code is also helpful for motivation!

    • @godnyx117
      @godnyx117 4 ปีที่แล้ว +2

      Lol! I was born in 2001. How old are you?

    • @AlFredo-sx2yy
      @AlFredo-sx2yy 2 ปีที่แล้ว +1

      @@godnyx117 now a year older than back when you asked :V

    • @godnyx117
      @godnyx117 2 ปีที่แล้ว +2

      @@AlFredo-sx2yy Lol, you are not wrong!

    • @roeetoledano6242
      @roeetoledano6242 ปีที่แล้ว

      @@AlFredo-sx2yy now 2 years...

  • @mequint2000
    @mequint2000 4 ปีที่แล้ว +51

    I once had an interview at 343 and one of the questions the interviewers asked me was to write an iterator for a tree data structure. Up to that point, I had never written an iterator in C++ not to mention for a less common DS, so I struggled through it. Didn't get the job but I remember the experience. Those who are watching - learn this! It may help land you a job in the industry.
    Thank you for this video - I found both the thought process and the code exercise useful!

    • @NordicFrog
      @NordicFrog 4 ปีที่แล้ว +2

      Did you actually interview at 343? The 343. That's cool, even if you did not get the job.

    • @godnyx117
      @godnyx117 4 ปีที่แล้ว

      Of course you didn't got the job! There is a reason people call them 343tard!

    • @dhruvgupta8747
      @dhruvgupta8747 3 ปีที่แล้ว +1

      Happened to me too a few days ago when interviewing for NVIDIA. Had to write an iterator for a linked list class but had no idea about how to write iterators :(

  • @davidb4020
    @davidb4020 4 ปีที่แล้ว +56

    Funny I just did an exam where I wished I had more knowledge on iterators and then decided to try and find more resources. Lo and behold! New video from the Cherno on iterators.

    • @StevenQiang
      @StevenQiang 4 ปีที่แล้ว +1

      comp6771?

    • @Sami-df7dj
      @Sami-df7dj 4 ปีที่แล้ว +1

      What did you get on the exam? Just curious see how well Cherno has taught you.

    • @jyliang2987
      @jyliang2987 ปีที่แล้ว +1

      @@StevenQiang Watching this video for my assignment 2

    • @StevenQiang
      @StevenQiang ปีที่แล้ว

      @@jyliang2987 Good luck with your assignment😆

  • @jessprogany4345
    @jessprogany4345 3 ปีที่แล้ว +17

    I always love when you explain library code

  • @mockingbird3809
    @mockingbird3809 4 ปีที่แล้ว +5

    Exactly what I was waiting for. Thanks, Cherno! Waiting for more C++ DS Videos!

  • @kryt7955
    @kryt7955 ปีที่แล้ว +2

    I love how you actually think about our learning experience and worry about it as a mentor would. Love you man. Keep up the great work!

  • @sathyababu9130
    @sathyababu9130 2 ปีที่แล้ว +3

    "2:51 I pull my Heart and soul into my Videos " Words uttered from your subconcious mind, your efforts, burning desire towards tech. will take yoiu a long way, I watched couple of your videos, I'm so impressed by the way you deliver. Bridge the gap between a novice developer and an architect. I can see you there. God bless you Cherno.

  • @joachimhodara575
    @joachimhodara575 4 ปีที่แล้ว +22

    Thanks for your videos, always nice to watch! Question: why implement VectorIterator instead of Iterator as a nested non-templated class in Vector? Is it because you could technically reuse it for another Array class (or any other random access container)?

    • @BetaNegative
      @BetaNegative 4 ปีที่แล้ว +3

      I was wondering this too.

  • @joymakerRC
    @joymakerRC 2 ปีที่แล้ว +1

    dude you are awesome , thanks , i needed you , and you came to me. so grateful

  • @PwnySlaystation01
    @PwnySlaystation01 4 ปีที่แล้ว +18

    I'm all for reading code to learn, but my god, the STL seems like it was written as part of a contest to see who could write the most obfuscated and difficult to understand code.

    • @PwnySlaystation01
      @PwnySlaystation01 4 ปีที่แล้ว +3

      Haha just got to the part where you mentioned this yourself

  • @isaactong3054
    @isaactong3054 4 ปีที่แล้ว

    I've been waiting for this video for quite a while. Thank you Cherno!

  • @Devilextremeful
    @Devilextremeful ปีที่แล้ว +1

    Thanks; this was really useful and straight to the point.

  • @ibraheeminam4982
    @ibraheeminam4982 4 ปีที่แล้ว +3

    Thank you so much for your amazing lectures. Would you please make an introductory lecture on Boost Library? Where should we use it?
    Also please make a video on different ways to design the code architecture in different types of large projects. Like thread based, or state machines based etc.
    Lastly, the c++ coding standards.
    I couldn't find good content on these topics so far. Thanks.

    • @krisitak
      @krisitak 4 ปีที่แล้ว +3

      Search for Bo Qian in youtube. Cherno + Bo Qian are one of the best C++ channels out there. Bo Qian covers the topics you asked for.

  • @timhaynes6735
    @timhaynes6735 2 ปีที่แล้ว

    Thanks Cherno - this is a nice "quick and dirty" implementation. For people interested to make solid safe real versions of the nice example here you must also: 1. add some protective code to prevent the increment/decrement operators from running off the ends of the array. 2. Decide how you want to handle dereferencing an iterator that is "invalid" (as well as pointer access). With a little work to tidy it up you can have a safe version. Mine currently will stop decrementing and "stay" on the first valid array value if you try to decrement off the end. I'm still thinking about best approaches and may test out the std behavior and just mimic same behaviors.

    • @timhaynes6735
      @timhaynes6735 2 ปีที่แล้ว

      Also - implementing the operator[ ] on the iterator itself is not conventional and would be confusing IMO. There's likely an operator [ ] on your container "itself" if it makes sense for that kind of container

  • @LetsDark
    @LetsDark 3 ปีที่แล้ว +2

    I would love a video about Iterators with a complex type, like a graph (a tree or something like hat). Everything in this video was easy, but what do you do, if you have to make a decision in the operator++? E.g. go to the child element or to a neighbor? And how do you track, which decision you made where? Lets say you go to the childs first, then you have to get the first neighbor after the last child. How do I do this, without creating a very complex iterator that has to track everything somehow?

  • @lukasz_kostka
    @lukasz_kostka 2 ปีที่แล้ว

    You've just explained this in shortest possible way for me. It works ! THX. I'd post a link to godbolt but youtube .....

  • @Raspredval1337
    @Raspredval1337 4 ปีที่แล้ว

    one day I was struggling with template argument lists, so I just opened the std::thread implementation in Visual Studio and copypasted a lot of code, tinkering with it. It helped a lot in understanding reference forwarding, storing arg lists in tuples and then invoking callbacks from that tuples. And now I've even managed to make a constrained template tuple-based hash-table for passing some data to the lua-machine.

  • @mario7501
    @mario7501 4 ปีที่แล้ว +2

    I actually wrote my own vector class a couple of years ago and had the exact same issue with non primitive types. Took ages to figure out what was going wrong :D

  • @bharanidharans5857
    @bharanidharans5857 3 ปีที่แล้ว

    Thanks for clear explanation and I tried implementing the customer iterator. I feel happy. Now I am able to understand the backends of STLs in effective manner. Thanks a lot. Please do post video for internal implementation of Maps, Multimap

  • @bulentgercek
    @bulentgercek 4 ปีที่แล้ว

    Great as always. Much love.

  • @xardinlume7345
    @xardinlume7345 3 ปีที่แล้ว +2

    I usually try to check the standard libraries, but all the macros, debug, fancy underscores... it all just makes it confusing. So thanks for decrypting it.

  • @hhehe24
    @hhehe24 2 ปีที่แล้ว

    2:50 this is incredibly helpful as an aid for a uni course, for me at least; very helpful

  • @leocarvalho8051
    @leocarvalho8051 4 ปีที่แล้ว +1

    Hi Cherno. Kudos from cape verde. Please make a series on popular projects code walktrough

  • @oscarahlke1585
    @oscarahlke1585 4 ปีที่แล้ว

    Hey man!
    First I wanted to tell you, that I really appreciate your tutorials man!
    But my question to the typenames is:
    Why do you have to create always a new pair of shoes?
    For example
    ...
    ReferenceType = T&
    Why not just typing T over and over again?
    Or has it something to do with the inheritance of classes?
    Thank you for your answer already! :-)
    And, even though Corona shatters the normal life:
    Merry Christmas!

    • @stepanhrbek8151
      @stepanhrbek8151 3 ปีที่แล้ว +1

      Hello, I am not expert at the topic, but I think it just makes the code more readable (probably not for everyone though). Have a good day!

  • @lerdi
    @lerdi 3 ปีที่แล้ว

    That keyboard typing is just soo satisfying

  • @Brick-il8on
    @Brick-il8on 10 หลายเดือนก่อน

    There are no subtitles in this issue. If you can cherno, thank you for adding it.

  • @alltheway99
    @alltheway99 4 ปีที่แล้ว +1

    Long time no see 😂
    You have a backlog of c++ topics you have to catch up man 🙂

  • @Yupppi
    @Yupppi ปีที่แล้ว

    People just don't usually send me some good code they made to solve some industry problem that is at all readable. I'm not saying one of those things don't happen in the chain of events, none of those things exist in my life. So as a beginner I'm slightly lacking the source. And often times it also happens that you're trying to find a syntax for a simple problem you're trying to solve and think you know the way logically, but you're missing the correct syntax, and you find stack overflow doing some crazy convoluted method to what can be solved with a short line of code.
    I'm at the level where I've never had to allocate to heap even though I've learned to do that. It's not quite the tools missing but applications. For most of my uses I'm interested in collecting a bit of information from the user or file, then operating on them and printing the results out. The biggest interest often is "how do I do this arithmetic operation chain in compact length with efficiency". Or "how on earth will I 1. make a matrix and print it 2. solve making an intuitive interface for inputing a matrix in prompt 3. do matrix calculations without writing painstaking manual element by element chain of loops or picking elements by hand 4. how do I generalize it for more than my template size matrix" etc.
    Your operator overload (conveniently as a demonstration of x, y, z struct that represented a vector) solved the printing for virtually any custom class neatly inside the code. Also I saw a compact method from std libraries to sum the rows together as if you did M*(1, 1, 1) matrix calculation similar to some example exercises on vector math classes. But I also saw a demonstration of how you'd do nxn matrix multiplied with nxn matrix and got upset at like 5 nested for loops that you'd manually make to iterate through everything in the matrix (supposedly making it like 100 times slower than individual arithmetic operations would predict due to the way of using cache).
    This is just semantics or philosophical pondering, not personally aimed to criticize or anything like that (all the videos are highly helpful) but don't you find it funny to state that most students have the issue of relying on documentation and videos when they should be reading real code and how the standard library does things, and also saying that when you wrote an iterator, you hadn't been taught it. In a video you released to demonstrate to people how to do it and giving tools to write and make things with code. I agree that you're correct in what you say, but what you do is immensely helpful, because I barely have time to sleep in engineering school and I assure you, learning C++ past very basics that allows you to write simple crude programs to maybe help you with some school tasks is not the priority. Without these videos I either wouldn't get a better understanding on C++ or I'd spent most of my time trying to understand stuff like CPPreference and bang my head against the wall to try to get some things to work and get no school work and studying done.
    Lastly after all the rambling, I must say I love the hue of orange your Visual Studio has. I'm using VS Code because it seemed like the best combo for me: doesn't take ages to open up and seemingly have a lot of weight pulled around when you try to use it, but similar enough to Visual Studio with all the convenient editing help and tools. However it has in some sense quite pastel, light and faded. And I'm really struggling to customize it for now, there's no color map outside the template themes where you could just choose the type of thing to color and choose the color, it just throws you in an empty .json to write your own definitions in who knows what syntax. That's a future project, to make it look pleasantly vivid like your Visual Studio. Funnily enough VSC made sure I noticed from the coloring of the words that there was a } missing where you had it, everything was just grey instead of the variable colors because it would no longer declare the m_Data, m_size and m_Capacity.

  • @amantiwari4736
    @amantiwari4736 4 ปีที่แล้ว +1

    please do a DS full series 😍😍

  • @marilynwen7179
    @marilynwen7179 2 ปีที่แล้ว +1

    Does anyone know if he shares the code to the public and where that is? Thanks!!

  • @nextwave5164
    @nextwave5164 4 ปีที่แล้ว +4

    How I taught myself to code was to find some code examples then hack it apart to do what I wanted. Lots of headaches and lots of yahoos with that lol

  • @YRBYD
    @YRBYD 4 ปีที่แล้ว +1

    Great Video! Is your VS color scheme somewhere available for download? Really like it

  • @korara3508
    @korara3508 2 ปีที่แล้ว +1

    why Vector::ValueType is used .I don't understand the syntax .I mean I only know that Classname::something is used when something is static in that class.Can anyone please explain that to me.thank you very much!

  • @Byynx
    @Byynx 10 หลายเดือนก่อน +2

    Could someone explain me what the scope resolution operator :: is doing before the call of some operator() functions? Like ::operator new()

    • @gerfggrgr8975
      @gerfggrgr8975 4 หลายเดือนก่อน

      Check out placement new and placement delete, it allows for separation of allocation and construction of an object

  • @mallasarjsulebhanvi4128
    @mallasarjsulebhanvi4128 ปีที่แล้ว

    Thanks Cherno, It was really a good learning experience

  • @peternjorogej
    @peternjorogej 4 ปีที่แล้ว +1

    How about linked lists (std::list) next? I would really like to see how iterators would work with data structures such as lists😅...

  • @kicchu15
    @kicchu15 4 ปีที่แล้ว

    Hello Cherno your videos are great. Also it would be great if you can possibly post some videos on Design patterns and Data Structures.

  • @MaxRaskin
    @MaxRaskin 4 ปีที่แล้ว

    HI, thanks for the neat tutorial! There's one minor bug in your prefix operator implementation - is implemented in terms of a postfix operator, should be ++m_Ptr instead of m_Ptr++;
    Cheers

  • @mattiacolombo6246
    @mattiacolombo6246 3 ปีที่แล้ว +1

    I can never thank you enough for your work on this series.
    I wanted to ask something, at 16:33, about the postfix operator. Shouldn't you make operator++(int) returning const VectorIterator instead of just VectorIterator, to prevent users from concatenating them like it++++? Since returning a const VectorIterator, you'd disable all non-const methods, making any subsequent ++ illegal. Not sure if the same logic applies to the prefix operator...

  • @Phroggster
    @Phroggster 4 ปีที่แล้ว +7

    That was a pretty good intro to iterators, as well as how to use them for enumerating data types. I do wish that you'd have kept the _NODISCARD macros intact as well as all the const mechanisms that the MSVC implementation provides as they can help catch problems early on as well as increase performance. But again, entry-level, I understand why most of that stuff was omitted.
    I hope that you, the person reading this whomever you may be, are doing well.

    • @SumoCumLoudly
      @SumoCumLoudly 4 ปีที่แล้ว +3

      I think its a terrible intro, hes jumping around all over the place of existing code without explaining anything really. "Lets make this a template" and gives no insight as to why, its pretty much copy and paste stuff and poorly done as a stand-alone video. Get the impression her doesnt fully understand them himself but is just making it work.

    • @AlFredo-sx2yy
      @AlFredo-sx2yy 2 ปีที่แล้ว

      @@SumoCumLoudly gotta fully agree with you, this has to be the first vid i've seen where cherno actually seems to be copy pasting stuff without actually getting what is going on under the hood. Shameful display tbh.

  • @ianpan0102
    @ianpan0102 4 ปีที่แล้ว +2

    Question: If we don't write "using ValueType = T" in the Vector class, is there any way for us to use Vector::T in the VectorIterator class?

  • @Alexino-xi1mn
    @Alexino-xi1mn 4 ปีที่แล้ว

    I'm a beginner ,and i'm far behind with the vids but i wanted to ask you if you could show us how can we implement all the things you showed us in the proces of making a simple game.

  • @darshitnasit3130
    @darshitnasit3130 4 ปีที่แล้ว +3

    Can anyone explain why at 11:24 he has use
    using ValueType = typename Vector::ValueType ??
    Why we can't use
    using ValueType = Vector::ValueType

    • @damnstupidoldidiot8776
      @damnstupidoldidiot8776 4 ปีที่แล้ว +1

      I have no idea, but you kind of just do, the compiler will throw an error and tell you to put typename.

    • @mequint2000
      @mequint2000 4 ปีที่แล้ว +2

      My understanding is that the Vector::ValueType is a templated type defined when the template is instantiated. The iterator relies on the typename specifically, not the type. Therefore, the 'typename' keyword is necessary to ensure that the iterator and the container the iterator is working on is in sync.
      Search 'C++ typename' for further details.

    • @Raspredval1337
      @Raspredval1337 4 ปีที่แล้ว

      @@mequint2000 idk, if the only practical way of getting the iterator is using begin/end/find, the type is already instantiated, so what's the point?

    • @mequint2000
      @mequint2000 4 ปีที่แล้ว

      @@Raspredval1337 I'm not sure I understand the question - what is the point of the iterator or the 'using' statement that syncs the iterator to its related template's contained class?

  • @eduardovaldez4013
    @eduardovaldez4013 3 ปีที่แล้ว

    quick question chenro, how do you get that color theme for your Visual studio. Mostly how do you change the colour of clases and strucutres. I unfortunately have to use Visual Studio at work instead of VS code so I'm a bit lost. I find that changing the colours really helps me keep track of what my code is doing.

  • @kamkamkil1
    @kamkamkil1 4 ปีที่แล้ว

    hi are you going to make video about the newer iterator introduced in cpp20 ? i mean with tags and everything

  • @nguyenacquan2977
    @nguyenacquan2977 3 ปีที่แล้ว

    why dont you realocate memory in Vector class by some magic like memcpy and just call operator delete( ptr, ...) later , it will assume the ptr you pass in is a void pointer so it will not call the destructor anyway

  • @linternetsansfil4152
    @linternetsansfil4152 4 ปีที่แล้ว +4

    You can use std::construct_at() or something similar instead of placement new, it looks cleaner. Could you make a video for how to implement a property class without any overhead ?

  • @codingsaroj18
    @codingsaroj18 4 ปีที่แล้ว

    I once wrote a unified style iterator that works for all data structures but it needed some functions to be implemented in the data structures. What's the advantage of a specific iterator over a common iterator?

  • @cmdlp4178
    @cmdlp4178 4 ปีที่แล้ว

    Iterators do not nessesarily belong to containers. You can write iterators to implement infinite/lazy datastructures. The simplest example I came up with is the numeric range, like pythons range:
    struct NumberIterator {
    int i;
    NumberIterator& operator++() {
    ++i;
    return *this;
    }
    constexpr int operator*() const {
    return i;
    }
    constexpr bool operator!=(NumberIterator const& other) {
    return i != other.i;
    }
    };
    struct Range {
    int a, b;
    constexpr NumberIterator begin() const {
    return {a};
    }
    constexpr NumberIterator end() const {
    return {b};
    }
    };
    int main() {
    for(int i : Range{1, 6}) {
    std::cout

  • @prajyotgajane1528
    @prajyotgajane1528 4 ปีที่แล้ว

    Please make a video on allocator's !!!

  • @embeddedbastler6406
    @embeddedbastler6406 3 ปีที่แล้ว

    Coming from Rust, implementing Iterators is kind of the same thing, but in Rust it feels like a bit better integrated into the language.

  • @baardi2
    @baardi2 3 ปีที่แล้ว

    Whats up with indexing on the iterator? What's that useful for?

  • @itihaasa9061
    @itihaasa9061 3 ปีที่แล้ว

    Can someone please share the link where implementation of vector or for that matter entire STL can be found.

  • @foodsweets2728
    @foodsweets2728 4 ปีที่แล้ว +4

    Playback Speed = 0.75, and you will understand every thing.

  • @paulzupan3732
    @paulzupan3732 ปีที่แล้ว

    Is there any reason not to just use emplace_back all the time, since it’s more efficient?

    • @paulzupan3732
      @paulzupan3732 6 หลายเดือนก่อน

      Nevermind, I thought about it for about a year and realized that there are some instances in which objects can't be constructed in-place (e.g. returned from a function from an external library), or it's simply not worth it (e.g. for primitive types).

  • @peanutbutter8885
    @peanutbutter8885 ปีที่แล้ว

    I love it, I just have to watch it at 0.75x, my brother, you are talking super fast.

  • @RuthlessShinobi
    @RuthlessShinobi 4 ปีที่แล้ว +1

    the cherno

  • @Adam_Lyskawa
    @Adam_Lyskawa 2 ปีที่แล้ว

    Finally, I've done iterator over my custom collection of indexable history items. As I couldn't use the pointer alone, because it wouldn't work with my collection ordering, I used the iterator that gets the index in constructor. Works as charm, it iterates from most recently added items, can also be reused with different indexable collections. Is there a neat syntax to use the same iterator to iterate backwards in C++17?

  • @pavelperina7629
    @pavelperina7629 4 ปีที่แล้ว

    Have someone tried alternatives to std library and compare performance and compile times?
    AFAIK it's much faster in gcc/clang debug builds than in msvc, cause msvc version does many checks in debug and some of them are (i think) even locking some mutexes.
    But there are other implementations such as eastd

  • @coenfuse
    @coenfuse 4 ปีที่แล้ว +1

    Godbless TH-cam's playback speed option

  • @tamelo
    @tamelo 3 ปีที่แล้ว

    WHere is the source code?
    It is impossible to follow going up and down the page.

  • @daniilmurray3751
    @daniilmurray3751 4 ปีที่แล้ว

    FINALLY.

  • @alyhilin
    @alyhilin 3 ปีที่แล้ว

    Does anybody has the source code for this? Reading the STL gives me a headache.

  • @kunalmuley09
    @kunalmuley09 2 ปีที่แล้ว

    11:55 How m_data pointer of Vector class is stored in Vector Iterator class

  • @milos5247
    @milos5247 4 ปีที่แล้ว

    What is theme he is using for VS?

  • @Sami-df7dj
    @Sami-df7dj 4 ปีที่แล้ว +6

    For the second channel could you react to the 13 min Black myth: Wukong. The game looks very advanced. It’s like next gen of next gen. I think other people may be wanting to see this game as well in the perspective of someone like you. I don’t mind if you don’t do it though I will still love you content.

  • @omarshahin4881
    @omarshahin4881 4 ปีที่แล้ว

    Would you put source file here please or any link to the source file, please?

  • @skyeplus
    @skyeplus 4 ปีที่แล้ว +1

    It's better to stick to naming conventions of STL/boost and use value_type, reference, pointer, etc., so your custom containers could interoperate with them.

  • @Sl33pySt3rdust
    @Sl33pySt3rdust 19 วันที่ผ่านมา

    people need to realize that you cant learn every single c++ feature in and out in one night

  • @gamingtech276
    @gamingtech276 4 ปีที่แล้ว

    Isn't the operator!= a bug? First you compare this.m_Ptr in the == overload member vars, then in the != you compare this with other? Isn't it more safe to always use a previously created method and just invert it (if invertable)? Such as you did with increment operators?

    • @ianpan0102
      @ianpan0102 4 ปีที่แล้ว +2

      He is exactly using the previously created operator== method to code the operator!=.
      The following two definition of operator!= will be equivalent, IF the operator== has been defined:
      1.) m_Ptr != other.m_Ptr
      2.) !(this == other)

  • @AnalogDude_
    @AnalogDude_ 4 ปีที่แล้ว +1

    most compilers want: for(unsigned long i = 0; i < values.size(); i++)

    • @32gigs96
      @32gigs96 4 ปีที่แล้ว +1

      step aside noob. we gotta needlessly overcomplicate this for no reason. i want those compile times DOUBLED!

  • @dc7538
    @dc7538 4 ปีที่แล้ว +1

    Hi, is there any other way to open/find that vector class file, because I don't use visual studio, thanks in advance.

    • @Raspredval1337
      @Raspredval1337 4 ปีที่แล้ว

      your compiler typically has the std::lib headers in it's include directory somewhere in the compiler files, try searching there

  • @rafalmichalski4893
    @rafalmichalski4893 4 ปีที่แล้ว

    Finally bug with missing placement new fixed (I pointed it under Vector video).

  • @gower1973
    @gower1973 4 ปีที่แล้ว

    The command and conquer code base was released open source, maybe you could do a video series on it, walking us through it.

  • @djllesh
    @djllesh 4 ปีที่แล้ว +1

    What theme is he using in Visual Studio? I want that so badly

    • @Avryg00
      @Avryg00 4 ปีที่แล้ว +1

      Hes using visual assist which is a paid add on for visual studio

    • @djllesh
      @djllesh 4 ปีที่แล้ว

      @@Avryg00 I mean the code style. I know that it can be his own custom style, but maybe someone knows, where to get something simillar

  • @cicciobombo7496
    @cicciobombo7496 4 ปีที่แล้ว +1

    asking someone to read stl code is something i wouldn't wish to my worst enemy

  • @AnalogDude_
    @AnalogDude_ 4 ปีที่แล้ว

    grrrr, can you use a pastebin and paste the code in there, place the link in the discription, i can't follow you and type it over, you're going to fast up & down.
    Qt Creator has the GNU ISO C++ Library.

  • @blank-vw2sb
    @blank-vw2sb 3 ปีที่แล้ว

    2:02
    "keyboard exercises"

  • @rodionsabbath9722
    @rodionsabbath9722 4 ปีที่แล้ว +1

    Hey Cherno! What's your C++ book recommendation?

  • @杨基永
    @杨基永 9 หลายเดือนก่อน

    this video's not getting captions 😂,well i'll take it as an exercise

  • @antonaparin
    @antonaparin 3 ปีที่แล้ว

    That's too hard to understand. Couldn't you do everything from scratch and not switch files so much?

  • @ataulfogomezgarcia5433
    @ataulfogomezgarcia5433 4 ปีที่แล้ว +1

    Could someone please tell me which font and theme is he using?
    Thanks in advance.

  • @luandkg
    @luandkg 4 ปีที่แล้ว

    Great 😙😙😙😙😙

  • @wazydotmeter
    @wazydotmeter 4 ปีที่แล้ว

    I have never seen that episode up their, Have you

  • @ronitech7802
    @ronitech7802 4 ปีที่แล้ว

    Does C++ have any inbuilt mechanism to add iterator support to user defined structures?

    • @Raspredval1337
      @Raspredval1337 4 ปีที่แล้ว

      nope, and for a good reason. Iterators are designed to be a black box over indexing container's elements. And it's up to the user to provide one, which is more suitable for the use case

  • @SpicyCurrey
    @SpicyCurrey 4 ปีที่แล้ว

    Nice

  • @meyvy3792
    @meyvy3792 4 ปีที่แล้ว

    great video,what the name of your theme thoXD

  • @bartoss92
    @bartoss92 4 ปีที่แล้ว

    Well, I've watched this video without watching the "making vector class" video and that piece of Vector::ReAlloc function you showed here looks like some elvish magic :D

  • @AnalogDude_
    @AnalogDude_ 4 ปีที่แล้ว

    that is Microsoft standard library

  • @RoshanPradhan2
    @RoshanPradhan2 4 ปีที่แล้ว +1

    Hey Cherno, can you recommend me a laptop under 100k rupees?

  • @RuthlessShinobi
    @RuthlessShinobi 4 ปีที่แล้ว

    the chern

  • @aryanparekh9314
    @aryanparekh9314 4 ปีที่แล้ว

    Helpful? The standard way to learn C++ is to read textbooks and watch The Cherno videos

  • @Beatsbasteln
    @Beatsbasteln 4 ปีที่แล้ว

    can we please have a moment where we talk about how you did this thing where you changed a bunch of stuff from different lines of code at the same time in around 17:30-17:34? wtf, magic

    • @ilkeraktug6685
      @ilkeraktug6685 4 ปีที่แล้ว +2

      Visual Studio feature. Alt+Shift+ Up Arrow Key

    • @Beatsbasteln
      @Beatsbasteln 4 ปีที่แล้ว

      @@ilkeraktug6685 thx

  • @focus9099
    @focus9099 4 ปีที่แล้ว

    how long have you been doing this "hey what's up guys" with the hands? It's pretty cool :)

  • @catinwall4256
    @catinwall4256 4 ปีที่แล้ว

    hi

  • @irmadavitashvili9359
    @irmadavitashvili9359 2 ปีที่แล้ว

    Hello! It's very interesting but your speech is very fast and it is hard to understand for not native speakers, please speak more slowly :)

  • @conflikt89
    @conflikt89 4 ปีที่แล้ว

    jeez that intro really channeled peter mckinnon

  • @airbus5717
    @airbus5717 ปีที่แล้ว

    Ah yes, msvc is simple !!!!!!!!!!