[Qt-interest] [ANN] ODB C++ ORM adds support for Qt

Andreas Pakulat apaku at gmx.de
Fri Apr 29 12:52:02 CEST 2011


On 29.04.11 14:03:23, Konstantin Tokarev wrote:
> 29.04.2011, 13:23, "Boris Kolpackov" <boris at codesynthesis.com>:
> > Agree. Our goal with lazy pointers was to "blend in" as much as
> > possible with the default Qt configuration. But perhaps we should
> > also add QT_BEGIN_NAMESPACE and QT_END_NAMESPACE. Or perhaps even
> > do something like this to allow the user to put lazy pointers to a
> > different namespace:
> >
> > if defined(ODB_QT_BEGIN_NAMESPACE)
> > ODB_QT_BEGIN_NAMESPACE
> > elif defined(QT_BEGIN_NAMESPACE)
> > QT_BEGIN_NAMESPACE
> > endif
> >
> > // Lazy pointer code.
> >
> > if defined(ODB_QT_END_NAMESPACE)
> > ODB_QT_END_NAMESPACE
> > elif defined(QT_END_NAMESPACE)
> > QT_END_NAMESPACE
> > endif
> >
> 
> I don't think it's a good style to do such tricks. It's better to place your code in your
> own namespace. User always will be able to add scope operator :: or using.
> Also, there will be no trouble if someday one adds class "QLazySharedPointer" to Qt.

In particular if the Qt provided QLazySharedPointer has slightly
different semantics than the one in ODB you'll get into a hell lot of
trouble as depending on the order of includes you may use one or the
other. In best case you get linking errors, in worst case you never know
which class is being used and end up with strange errors that are hard
to reproduce.

Really, naming a class QXXX in a Qt-related project without putting it
into a custom namespace is really bad practice unless Qt comes with its
own namespace in Qt 5 or later.

Andreas




More information about the Qt-interest-old mailing list