C++11 observer pattern (signals, slots, events, change broadcaster/listener, or whatever you want to call it)

前端 未结 5 1487
囚心锁ツ
囚心锁ツ 2021-01-30 04:41

With the changes made in C++11 (such as the inclusion of std::bind), is there a recommended way to implement a simple single-threaded observer pattern without depen

5条回答
  •  不知归路
    2021-01-30 04:54

    I have had a go at this myself also. My efforts can be found at this gist, which will continue to evolve . . .

    https://gist.github.com/4172757

    I use a different style, more similar to the change notifications in JUCE than BOOST signals. Connection management is done using some lambda syntax that does some capture by copy. It is working well so far.

提交回复
热议问题