100DaysOfGameDev: Day 19

The chapter follows with more discussion on initialize_lists and constructors in classes. It covers cases, when ambiguity arises about which one to use, such as

struct X {
    X(initialized_list<int>);
    X();
    X(int);
}

X x0 {};    // empty list: default constructor or initializer-list constructor? (the default constructor )
X x1 {1};    // one integer; an int argument or a list of one element? ) the initializer-list constructor )

It also, reminds us of the correct use for initilizer_list, keeping in mind the values are immutable. The next topic was copy and move for classes. The terms of shallow and deep copy were discussed. The author also talked about the technique of combining the good of both worlds, that is 'copy-on-write'. It's fine for a state should be shared if it's immutable and used only for reading, however, nasty errors can occur if it's used for write. That's it for today, see you tomorrow!