boost::openmethod::virtual_ptr::cast
Cast to another virtual_ptr type
Synopsis
Declared in <boost/openmethod/core.hpp>
template<class Other>
requires std::is_base_of_v<element_type, Other> ||
std::is_base_of_v<Other, element_type>
decltype(auto)
cast() const;
Example
Dog snoopy;
virtual_ptr<Animal> animal(snoopy);
auto dog = animal.cast<Dog>();
BOOST_TEST(dog.get() == &snoopy);
BOOST_TEST(dog.vptr() == animal.vptr());
Template Parameters
Name |
Description |
Other |
The target class of the cast |
Created with MrDocs