Last active
October 11, 2016 19:58
-
-
Save jleben/2dd353cfff1accae25b627edeb767ad5 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
class spacelike_impl { | |
public: | |
virtual spacelike_impl * coalesce() = 0; | |
}; | |
class spacelike | |
{ | |
public: | |
spacelike coalesce() { return p->coalesce(); } | |
protected: | |
spacelike(spacelike_impl * p): p(p) {} | |
private: | |
spacelike_impl * p; | |
}; | |
// ------- // | |
class set_impl : public spacelike_impl | |
{ | |
public: | |
spacelike_impl * coalesce() override { return do_coalesce(); } | |
set_impl * do_coalesce() { ... } | |
}; | |
class set : public spacelike | |
{ | |
public: | |
set(): set(new set_impl) {} | |
set coalesce() { return p->do_coalesce(); } | |
private: | |
set(set_impl *p): spacelike(p), p(p) {} | |
set_impl * p; | |
}; | |
// ------- // | |
class map_impl : public spacelike_impl | |
{ | |
public: | |
spacelike_impl * coalesce() override { return do_coalesce(); } | |
map_impl * do_coalesce() { ... } | |
}; | |
class map : public spacelike | |
{ | |
public: | |
map(): map(new map_impl) {} | |
map coalesce() { return p->do_coalesce(); } | |
private: | |
map(map_impl *p): spacelike(p), p(p) {} | |
map_impl * p; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment