Chytrý ukazatel RefPtr
Glib::RefPtr is a smartpointer. Specifically, it is a reference-counting smartpointer. You might be familiar with std::unique_ptr<> and std::shared_ptr<>, which are also smartpointers. In gtkmm-4.0 Glib::RefPtr<> is an alias for std::shared_ptr<>, which is reference-counting. Glib::RefPtr<> was introduced long before there was a reference-counting smartpointer in the C++ Standard Library.
Chytré ukazatele fungují hodně podobně jako normální ukazatele.Zde je pár příkladů.
- A.1. Kopírování
- A.2. Snižování referencí
- A.3. Přetypování
- A.4. Checking for nullptr
- A.5. Bezkonstantnost