All pastes #620642 Raw Edit

Something

public text v1 · immutable
·published 2007-07-15 17:18 UTC
rendered paste body
#include <stc/any.hh>

template <class E>
class animal : public stc::any<E>
{
  public:
    bool is_happy() {
      return this−>exact().is_happy_impl();
    }
};

class cat : public animal <cat>
{
  public :
    bool is_happy_impl() { return true; }
};

class dog : public animal <cat>
{
  public :
    bool is_happy_impl() { return false; }
};

int main()
{
  cat c;
  dog d;

  c.is_happy(); // true
  d.is_happy(); // false
}