Created
December 2, 2008 01:31
-
-
Save benjamn/30937 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
typedef struct Nil {}; | |
template <typename H, typename T> | |
class Cons : public T { | |
protected: | |
typedef T BaseType; | |
H mVal; | |
public: | |
BaseType &operator()(H aVal) { | |
mVal = aVal; | |
return *static_cast<BaseType*>(this); | |
} | |
}; | |
class Foo : public Cons<int, Cons<char*, Cons<bool, Nil> > > | |
{ | |
}; | |
// later... | |
Foo foo; | |
foo(1)("asdf")(false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment