Guest User

Untitled

a guest
Feb 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. typedef struct Nil {};
  2.  
  3. template <typename H, typename T>
  4. class Cons : public T {
  5. protected:
  6. typedef T BaseType;
  7. H mVal;
  8. public:
  9. BaseType &operator()(H aVal) {
  10. mVal = aVal;
  11. return *static_cast<BaseType*>(this);
  12. }
  13. };
  14.  
  15. class Foo : public Cons<int, Cons<char*, Cons<bool, Nil> > >
  16. {
  17. };
  18.  
  19. // later...
  20. Foo foo;
  21. foo(1)("asdf")(false);
Add Comment
Please, Sign In to add comment