Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Of course the Rust features being used by that Event type are runtime polymorphism and type introspection, so another obvious C++ approach would be just to use a pointer to a virtual based class including the type, then:

switch (event->type) {

case EvKeyPressEvent:

  {

    auto kpe - dynamic_cast<KeyPressEvent*>(event)

    ...

  }

  break;

}


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: