Struct scoped_connection


#include <src/entt/signal/sigh.hpp>

struct scoped_connection


Scoped connection class.

Opaque object the aim of which is to allow users to release an already estabilished connection without having to keep a reference to the signal or the sink that generated it.
A scoped connection automatically breaks the link between the two objects when it goes out of scope.

Mentioned in

  • Events, Signals And Everything In Between / Signals


scoped_connectionDefault constructor.
~scoped_connectionAutomatically breaks the link on destruction.
operator boolChecks whether a scoped connection is properly initialized.
operator=Default copy assignment operator, deleted on purpose.
releaseBreaks the connection.


Lines 196-247 in src/entt/signal/sigh.hpp.

struct scoped_connection {
    /*! @brief Default constructor. */
    scoped_connection() = default;

     * @brief Constructs a scoped connection from a basic connection.
     * @param other A valid connection object.
    scoped_connection(const connection &other)
        : conn{other}

    /*! @brief Default copy constructor, deleted on purpose. */
    scoped_connection(const scoped_connection &) = delete;

    /*! @brief Automatically breaks the link on destruction. */
    ~scoped_connection() {

     * @brief Default copy assignment operator, deleted on purpose.
     * @return This scoped connection.
    scoped_connection & operator=(const scoped_connection &) = delete;

     * @brief Acquires a connection.
     * @param other The connection object to acquire.
     * @return This scoped connection.
    scoped_connection & operator=(connection other) {
        conn = std::move(other);
        return *this;

     * @brief Checks whether a scoped connection is properly initialized.
     * @return True if the connection is properly initialized, false otherwise.
    [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
        return static_cast<bool>(conn);

    /*! @brief Breaks the connection. */
    void release() {

    connection conn;

Add Discussion

Log in to comment