Skip to content

Instantly share code, notes, and snippets.

@benjamn
Created December 2, 2008 01:31
Show Gist options
  • Save benjamn/30937 to your computer and use it in GitHub Desktop.
Save benjamn/30937 to your computer and use it in GitHub Desktop.
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