I love Haskell style pattern matching.

I have my C++ code as follows:

```
ObjectPtr ptr;
if(ptr.isType<Foo>()) { // isType returns a bool
  Ptr<Foo> p = ptr.convertAs<Foo>(); // convertAs returns a Ptr<Foo>
  ......
}
if(ptr.isType<Bar>()) {
  Ptr<Bar> p = ptr.convertAs<Bar>();
  ......
}

```

Now, are there any macros I can do define to simplify this? I have been pondering this for a while, but can't simplify it further.

Thanks!