[Xcb] Why is xcb_leave_notify_event_t a typedef?

Josh Triplett josh at joshtriplett.org
Sun Sep 5 10:35:51 PDT 2010


On Sun, Sep 05, 2010 at 04:46:42PM +0200, Ulrich Eckhardt wrote:
> The question is why this is a typedef for xcb_enter_notify_event_t instead of 
> a separate type? The problem I had with this was when creating an overloaded 
> C++ function to format this as a string - you can't create overloads for 
> typedefs, which are mere aliases, you need separate types instead.
> 
> Is this necessary for something or was it just convenience?

Not strictly necessary, but the two events do have precisely the same
structure.  Having them as effectively the same type allows code which
wants to handle them similarly to share code.  You can always
distinguish the events by checking response_type.

To the extent this particular design decision received any serious
thought before, the two possibilities seemed entirely equivalent for any
possible use case, except for those where the typedef alias potentially
allowed sharing more code.  I think I can safely say that C++ overloads
hadn't ever occurred to any of us. :)

- Josh Triplett


More information about the Xcb mailing list