Difference between revisions of "Intermediate C++ Game Programming Tutorial 21"
From Chilipedia
(→Source Code) |
|||
Line 1: | Line 1: | ||
− | Smart pointers. I have the smartest pointers. | + | Smart pointers. I know pointers, I have the smartest pointers. In this video we learn about <code>std::unique_ptr<></code>, which is by far the most frequently-used and important smart pointer. <code>std::shared_ptr<></code> can go suck on an egg. |
== Topics Covered == | == Topics Covered == | ||
− | * std::unique_ptr<> | + | * <code>std::unique_ptr<></code> |
+ | * How to pass (and not to pass) smart pointers | ||
+ | * Custom deleters | ||
== Video Timestamp Index == | == Video Timestamp Index == | ||
Line 9: | Line 11: | ||
== Bonus Video == | == Bonus Video == | ||
Coming soon (Surface final form)! | Coming soon (Surface final form)! | ||
+ | |||
+ | == Notes == | ||
+ | Although Chili uses <code>std::unique_ptr<></code> in <code>Surface</code>, which allows us to <code>= default</code> the move members and leave the destructor undeclared, the astute student will realize that <code>Surface</code> should actually be setting the <code>width</code> and <code>height</code> of the donor surface to <code>0</code> when pilfering, so we actually still need to declare move members in this case. This is done in the Bonus Video where we perfect <code>Surface</code>. | ||
== Source Code == | == Source Code == | ||
* [https://github.com/planetchili/Inheritance Inheritance (Memefighter) Github Repository]<br /> | * [https://github.com/planetchili/Inheritance Inheritance (Memefighter) Github Repository]<br /> | ||
* [https://github.com/planetchili/Sprite Sprite Github Repository (for <code>Surface</code> code)]<br /> | * [https://github.com/planetchili/Sprite Sprite Github Repository (for <code>Surface</code> code)]<br /> | ||
+ | |||
== See also == | == See also == | ||
* [[Intermediate C++ Game Programming Tutorial 22|Next in series (Tutorial 22)]] | * [[Intermediate C++ Game Programming Tutorial 22|Next in series (Tutorial 22)]] | ||
* [[Intermediate C++ Game Programming Series]] | * [[Intermediate C++ Game Programming Series]] |
Revision as of 12:39, 13 January 2018
Smart pointers. I know pointers, I have the smartest pointers. In this video we learn about std::unique_ptr<>
, which is by far the most frequently-used and important smart pointer. std::shared_ptr<>
can go suck on an egg.
Topics Covered
-
std::unique_ptr<>
- How to pass (and not to pass) smart pointers
- Custom deleters
Video Timestamp Index
Bonus Video
Coming soon (Surface final form)!
Notes
Although Chili uses std::unique_ptr<>
in Surface
, which allows us to = default
the move members and leave the destructor undeclared, the astute student will realize that Surface
should actually be setting the width
and height
of the donor surface to 0
when pilfering, so we actually still need to declare move members in this case. This is done in the Bonus Video where we perfect Surface
.
Source Code