...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::signals2::scoped_connection — Limits a signal-slot connection lifetime to a particular scope.
// In header: <boost/signals2/connection.hpp> class scoped_connection : public connection { public: // construct/copy/destruct scoped_connection(); scoped_connection(const connection&); scoped_connection(scoped_connection&&); scoped_connection(connection&&); scoped_connection& operator=(const connection&); scoped_connection& operator=(scoped_connection&&); scoped_connection& operator=(connection&&); ~scoped_connection(); // public methods connection release(); private: // construct/copy/destruct scoped_connection(const scoped_connection&); scoped_connection& operator=(const scoped_connection&); };
A connection which automatically disconnects on destruction.
The methods of the scoped_connection
class (including those
inherited from its base connection
class) are thread-safe with the exception
of signals2::connection::swap, release, and
the assignment operator. A scoped_connection
object
should not be accessed concurrently when any of these operations is in progress.
However, it is always safe to access a different connection
object
in another thread, even if it references the same underlying signal-slot connection.
scoped_connection
public construct/copy/destructscoped_connection();
Default constructs an empty scoped_connection.
Postconditions: |
|
Throws: |
Will not throw. |
scoped_connection(const connection& other);
Effects: |
|
Postconditions: |
|
Throws: |
Will not throw. |
scoped_connection(scoped_connection&& other);
Move constructor.
Effects: |
|
Throws: |
Will not throw. |
scoped_connection(connection&& other);
Move constructor.
Effects: |
|
Throws: |
Will not throw. |
scoped_connection& operator=(const connection& rhs);
Copy assignment from unscoped connection.
Effects: |
|
Postconditions: |
|
Throws: |
Will not throw. |
scoped_connection& operator=(scoped_connection&& rhs);
Move assignment.
Effects: |
|
Throws: |
Will not throw. |
scoped_connection& operator=(connection&& rhs);
Move assignment.
Effects: |
|
Throws: |
Will not throw. |
~scoped_connection();
Effects: |
If
|
scoped_connection
public methodsconnection release();
Effects: |
Releases the connection so it will not be disconnected by the |
Postconditions: |
|
Returns: |
A connection object referencing the connection which was
released by the |
scoped_connection
private construct/copy/destructscoped_connection(const scoped_connection& other);
The scoped_connection class is not copyable. It may only be copy constructed from an unscoped
connection
object.
scoped_connection& operator=(const scoped_connection& rhs);
The scoped_connection class is not copyable. It may only be copy assigned from an unscoped
connection
object.