Over and over again we find ourselves in situations where we want to add
data members to a class without breaking ABI, That can be, and has been,
done in an ugly way. See e.g.
https://git.gnome.org/browse/libxml++/tree/libxml++/parsers/parser.cc
https://git.gnome.org/browse/glibmm/tree/glib/glibmm/main.cc
https://git.gnome.org/browse/glibmm/tree/glib/glibmm/objectbase.h
and the discussion at the end of
https://bugzilla.gnome.org/show_bug.cgi?id=727822#c3.
The pimpl (pointer to implementation) idiom, described at
http://en.wikipedia.org/wiki/Pimpl, offers a better solution. In a new
class, add
private:
struct Impl;
Impl* pimpl;
struct Impl is defined in the .cc file. It's not part of the ABI. It can
be changed without breaking ABI.
The drawback of using the pimpl idiom consistently is of course that it
requires an extra pointer in each object instance. In many classes,
those pointers will never be needed.
_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list