Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- template<typename Tag>
- struct result {
- /* export it ... */
- typedef typename Tag::type type;
- static type ptr;
- };
- template<typename Tag>
- typename result<Tag>::type result<Tag>::ptr;
- template<typename Tag, typename Tag::type p>
- struct rob : result<Tag> {
- /* fill it ... */
- struct filler {
- filler() { result<Tag>::ptr = p; }
- };
- static filler filler_obj;
- };
- template<typename Tag, typename Tag::type p>
- typename rob<Tag, p>::filler rob<Tag, p>::filler_obj;
- struct A {
- private:
- void f() {
- std::cout << "шах и мат, атеисты!" << std::endl;
- }
- };
- struct Af { typedef void(A::*type)(); };
- template class rob<Af, &A::f>;
- int main(int argc, char *argv[])
- {
- A a;
- (a.*result<Af>::ptr)();
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement