Casting

You can cast RefPtrs to base types, just like normal pointers.

auto refStore = Gtk::TreeStore::create(columns);
Glib::RefPtr<Gtk::TreeModel> refModel = refStore;

This means that any method which takes a const Glib::RefPtr<BaseType>& argument can also take a const Glib::RefPtr<DerivedType>&. The cast is implicit, just as it would be for a normal pointer.

You can also cast to a derived type, but the syntax is a little different than with a normal pointer.

auto refStore = std::dynamic_pointer_cast<Gtk::TreeStore>(refModel);
auto refStore2 = std::static_pointer_cast<Gtk::TreeStore>(refModel);