The order you declare variables in a struct or class matters! Member variables are put in memory in the order they are declared but they will be aligned/padded to blocks the size of the largest member. Generally its best to order member variables from smallest to largest or vice-versa.
The order you declare variables in a struct or class matters! Member variables are put in memory in the order they are declared but they will be aligned/padded to blocks the size of the largest member. Generally its best to order member variables from smallest to largest or vice-versa.
Ever needed a simple container that could optionally be empty? Well in the standard template library there is std::optional and its for just this! It can be evaluated as a boolean to see if its empty and filled or changed using the equal sign operator. This was added with C++17.
Ever needed a simple container that could optionally be empty? Well in the standard template library there is std::optional and its for just this! It can be evaluated as a boolean to see if its empty and filled or changed using the equal sign operator. This was added with C++17.
In the standard template library there is `std::pair`, and all it does is store two variables together. This sounds basic but can save you the trouble of making a lot of your own helper classes. I have been using it recently for storing vertex-cost pairs for Dijkstra's algorithm.
In the standard template library there is `std::pair`, and all it does is store two variables together. This sounds basic but can save you the trouble of making a lot of your own helper classes. I have been using it recently for storing vertex-cost pairs for Dijkstra's algorithm.
The 'ls' command is aware of when its output is being redirected or piped, if it is it changes its output to one file per line. This means you don't have to do any special processing to use its output in your scripts!
The 'ls' command is aware of when its output is being redirected or piped, if it is it changes its output to one file per line. This means you don't have to do any special processing to use its output in your scripts!
You can use references with range-based for loops to modify the contents of the data structure you are iterating over! Just make the looping variable a reference with an &.
The following program takes a vector of chars and makes them all lowercase. Its output would be "a, b, c, d, "
You can use references with range-based for loops to modify the contents of the data structure you are iterating over! Just make the looping variable a reference with an &.
The following program takes a vector of chars and makes them all lowercase. Its output would be "a, b, c, d, "