|
Boost : |
From: Karl Nelson (kenelson_at_[hidden])
Date: 2002-02-14 11:35:41
> On Wed, 13 Feb 2002, Karl Nelson wrote:
>
> >
> > Someone in this group must have been reading gtkmm code again.
> >
> > > >
> > > > #define PROPERTY(c, t, n) \
> > > > PropertyMaker< c, t >::Property<&c::Get##n, &c::Set##n> n
> > > >
> > > > template <typename Class, typename Data>
> > > > struct PropertyMaker
> > > > {
> > > > template <Data (Class::*Get)() const, void (Class::*Set)(Data)>
> > > > struct Property
> > > > {
> > > > Class* m_Class;
> > > > operator Data () const { return (m_Class->*Get)(); }
> > > > void operator=(Data data) const { (m_Class->*Set)(data); }
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> What is gtkmm? I've honestly never read its code, and this code I posted
> was 100% origianlly written by me.
Gtkmm is widget set at http://gtkmm.sourceforge.net
I wrote the property/signals as members using an anonyous union
several years back (1998). It was the first and only code I had seen
written which heavy uses of anonymous unions. (Not that others
likely haven't invented it numerous times.) It was a bad hack intended
to get the size of our objects which had dozens of signal proxies
per widget below the 64k class limit of gcc.
However, use of anonymous unions has proved so troublesome we are having
to drop it in the next major release. It really isn't worth it
to not simply use normal methods. Just take it from someone who
have made heavy use of the construct for many years, that it is
really against the standard to use anonymous unions in that
fashion.
However, if the standard would allow non-trivial classes in an
anonymous union and allow individual members of unions separate
access rights, then it would be a great idea.
--Karl
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk