fix typo and make alert non-copyable

This commit is contained in:
arvidn 2016-02-27 23:53:25 -05:00
parent f563bf9cac
commit 2f745a181c
2 changed files with 24 additions and 3 deletions

View File

@ -80,6 +80,9 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent {
// The ``alert`` class is the base class that specific messages are derived from.
// alert types are not copyable, and cannot be constructed by the client. The
// pointers returned by libtorrent are short lived (the details are described
// under session_handle::pop_alerts())
class TORRENT_EXPORT alert
{
public:
@ -283,10 +286,10 @@ namespace libtorrent {
#endif // TORRENT_NO_DEPRECATE
protected:
// the alert is not copyable (but for backwards compatibility reasons it
// retains the ability to clone itself, for now).
#if __cplusplus >= 201103L
alert(alert const&) = default;
#else
alert(alert const&);
alert(alert const& rhs) = default;
#endif
private:

View File

@ -163,7 +163,25 @@ namespace libtorrent
#define TORRENT_CLONE(name)
#endif
// we can only use = default in C++11
// the purpose of this is just to make all alert types non-copyable from user
// code. The heterogeneous queue does not yet have an emplace_back(), so it
// still needs to copy alerts, but the important part is that it's not
// copyable for clients.
// TODO: Once the backwards compatibility of clone() is removed, and once
// C++11 is required, this can be simplified to just say = delete
#if __cplusplus >= 201103L
#define TORRENT_PROTECTED_CCTOR(name) \
protected: \
template <class T> friend struct heterogeneous_queue; \
name(name const&) = default; \
public:
#else
#define TORRENT_PROTECTED_CCTOR(name)
#endif
#define TORRENT_DEFINE_ALERT_IMPL(name, seq, prio) \
TORRENT_PROTECTED_CCTOR(name) \
static const int priority = prio; \
static const int alert_type = seq; \
virtual int type() const TORRENT_OVERRIDE { return alert_type; } \