Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) BoostSignals2Example4

 

BoostQt CreatorLubuntu

 

Boost.Signals2 example 4 is a Boost.Signals2 example.

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppBoostSignals2Example4/CppBoostSignals2Example4.pro

 

include(../../ConsoleApplication.pri)
include(../../Libraries/Boost.pri)
SOURCES += main.cpp

 

 

 

 

 

./CppBoostSignals2Example4/main.cpp

 

#include <cassert>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#include <boost/signals2.hpp>
#pragma GCC diagnostic pop

void EmptySlot() {}

int main()
{
  boost::signals2::signal<void()> signal;

  //A signal is connected to no slots
  assert(signal.num_slots() == 0);
  signal.connect(EmptySlot);

  //Adding a slot increases num_slots
  assert(signal.num_slots() == 1);
  signal.connect(EmptySlot);

  //Adding the same slot again increases num_slots
  assert(signal.num_slots() == 2);

  //Disconnect that slot removes both connections
  signal.disconnect(EmptySlot);
  assert(signal.num_slots() == 0);
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml