...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
1. |
Don't noncopyable signal semantics mean that a class with a signal member will be noncopyable as well? |
No. The compiler will not be able to generate a copy constructor or copy assignment operator for your class if it has a signal as a member, but you are free to write your own copy constructor and/or copy assignment operator. Just don't try to copy the signal. |
|
2. |
Is Boost.Signals thread-safe? |
No. Using Boost.Signals in a multithreaded concept is very dangerous, and it is very likely that the results will be less than satisfying. Boost.Signals will support thread safety in the future. |
|
3. |
How do I get Boost.Signals to work with Qt? |
When building with Qt, the Moc keywords
For Qt 4.1 and later, This behavior
can be turned off in Qt on a per-project or per-file basis
with the CONFIG += no_keywords # so Qt won't #define any non-all-caps `keywords' INCLUDEPATH += . /usr/local/include/boost-1_33_1/ macx:LIBS += /usr/local/lib/libboost_signals-1_33_1.a # ...your exact paths may vary Now you can mix Boost.Signals and Qt Signals and Slots in the same files, and even within the same class or function. You will have to use the upper-case versions of Qt macros in your own code. See the article A Deeper Look at Signals and Slots [off-site] for more complete examples and a survey of the strengths of the two systems. Older versions of Qt did not provide a reliable mechanism for avoiding these unfriendly, all lower-case `keyword'-like macros. Although this is a problem with Qt and not Boost.Signals, a user can use the two systems together with a little extra effort. There are two ways to do this: The first way involves defining
the namespace boost { namespace signals = BOOST_SIGNALS_NAMESPACE; } The second way, provided by Frank Hess and improved by
Niels Dekker, involves
creating a header #ifndef SIGNALSLIB_HPP_INCLUDED #define SIGNALSLIB_HPP_INCLUDED #if defined(signals) && defined(QOBJECTDEFS_H) && \ !defined(QT_MOC_CPP) # undef signals # define signals signals #endif #include <boost/signal.hpp> namespace boost { namespace signalslib = signals; } #if defined(signals) && defined(QOBJECTDEFS_H) && \ !defined(QT_MOC_CPP) # undef signals // Restore the macro definition of "signals", as it was // defined by Qt's <qobjectdefs.h>. # define signals protected #endif #endif Use this header to include the Boost library, then refer
to it in the namespace |
Last revised: May 21, 2008 at 21:57:05 +0100 |