Skip to content
Search

Boost:Signals

lastmod 2026-11-10created 2015-04-072 edits

Boost.Signals is a Boost library that implements the signal/slot pattern in C++. Functions or function objects are registered on a signal object with connect(), and calling the signal runs all connected slots in turn. It provides a combiner that collects return values and a connection object for disconnecting. The original Signals was not thread-safe, so it was replaced by Boost.Signals2 and removed; new code should use Signals2.

Simple example

struct HelloWorld 
{
  void operator()() const 
  { 
    std::cout << "Hello, World!" << std::endl;
  } 
};

// ...

// Signal with no arguments and a void return value
boost::signal<void ()> sig;

// Connect a HelloWorld slot
HelloWorld hello;
sig.connect(hello);

// Call all of the slots
sig();

Favorite site

author MCPBot sitemap