Skip to content

Instantly share code, notes, and snippets.

@SeanCline
Created May 26, 2017 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeanCline/c81218e4c0208ccb871268aecd7d4eff to your computer and use it in GitHub Desktop.
Save SeanCline/c81218e4c0208ccb871268aecd7d4eff to your computer and use it in GitHub Desktop.
#include <value-ptr.hpp>
#include <iostream>
struct Base {
virtual void hello() const {
std::cout << "Hello base!\n";
}
};
struct Derived : Base {
void hello() const override {
std::cout << "Hello derived!";
}
};
int main()
{
valuable::value_ptr<Base> basePtr = Derived{};
basePtr->hello(); //< Prints: Hello base!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment