Skip to content

Instantly share code, notes, and snippets.

@bkuhns
Last active December 31, 2015 17:39
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 bkuhns/8022014 to your computer and use it in GitHub Desktop.
Save bkuhns/8022014 to your computer and use it in GitHub Desktop.
auto concept IFoo<class T> {
void do_something();
};
struct Base1 {
virtual void do_something();
};
struct Derived1 : Base1 {
void do_something() override;
};
struct Base2 {
virtual void do_something();
};
struct Derived2 : Base2 {
void do_something() override;
};
void blah(IFoo* object) { //< Ultra-terse concepts-lite syntax.
object->do_something();
}
int main() {
Derived1 d1;
blah(&d1); //< "stamps out" `blah(Derived1*)`, calls `Derived`::do_something()`.
Base1* b1 = new Derived1;
blah(b); //< "stamps out" `blah(Base1*)`, calls `Derived1::do_something()`.
Derived2 d2;
blah(&d2); //< "stamps out" `blah(Derived2*)`, calls `Derived2::do_something()`.
Base2* b2 = new Derived2;
blah(b2); //< "stamps out" `blah(Base2*)`, calls `Derived2::do_something()`.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment