Observer design pattern in C++

前端 未结 7 977
礼貌的吻别
礼貌的吻别 2020-12-06 03:00

Is the observer design pattern already defined in STL (Like the java.util.Observer and java.util.Observable in Java) ?

7条回答
  •  無奈伤痛
    2020-12-06 03:50

    As far as my knowledge goes in C++, STL doesn't have an implementation for Observer pattern. There was a proposal for Signal/Slot for standard library in TR2 though.

    There are plenty of libraries which provides implementation for Observer pattern Qt library being one of the pioneers. The boost library has an implementation (see Boost::Signals & Boost::Signals2).

    The Poco C++ library has a neat implementation of the observer pattern (see NotificationCenter).

    libsigc++, cpp-events are some of the other libraries that provide signal/slot implementations.

提交回复
热议问题