Last active
December 31, 2015 17:39
-
-
Save bkuhns/8022014 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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