Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards


Example programs

Miscellaneous Tutorial Examples
Postconstructors and Predestructors with deconstruct()

Miscellaneous Tutorial Examples


This example is a basic example of connecting a slot to a signal and then invoking the signal.

Download hello_world_slot.cpp.


This example extends the hello_world_slot example slightly by connecting more than one slot to the signal before invoking it.

Download hello_world_multi_slot.cpp.


This example extends the hello_world_multi_slot example slightly by using slot groups to specify the order slots should be invoked.

Download ordering_slots.cpp.


The slot_arguments program shows how to pass arguments from a signal invocation to slots.

Download slot_arguments.cpp.


This example shows how to return a value from slots to the signal invocation. It uses the default optional_last_value combiner.

Download signal_return_value.cpp.


This example shows more returning of values from slots to the signal invocation. This time, custom combiners are defined and used.

Download custom_combiners.cpp.


This example demonstrates various means of manually disconnecting slots, as well as temporarily blocking them via shared_connection_block.

Download disconnect_and_block.cpp.


This example demonstrates the passing of slot functions to a private signal through a non-template interface.

Download passing_slots.cpp.


This example demonstrates connecting an extended slot to a signal. An extended slot accepts a reference to its invoking signal-slot connection as an additional argument, permitting the slot to temporarily block or permanently disconnect itself.

Download extended_slot.cpp.



This is the document-view example program which is described in the tutorial. It shows usage of a signal and slots to implement two different views of a text document.

Download doc_view.cpp.


This program modifies the original doc_view.cpp example to employ automatic connection management.

Download doc_view_acm.cpp.


This program modifies the doc_view_acm.cpp example to use postconstructors and the deconstruct() factory function.

Download doc_view_acm_deconstruct.cpp.

Postconstructors and Predestructors with deconstruct()


This program is a basic example of how to define a class with a postconstructor which uses deconstruct() as its factory function.

Download postconstructor_ex1.


This program extends the postconstructor_ex1 example slightly, by additionally passing arguments from the deconstruct() call through to the class' constructor and postconstructor.

Download postconstructor_ex2.


This program is a basic example of how to define a class with a predestructor which uses deconstruct() as its factory function.

Download predestructor_example.