Comparing std::tr1::function<> objects

前端 未结 7 1659
粉色の甜心
粉色の甜心 2020-12-07 02:36

I\'ve been trying to implement a C#-like event system in C++ with the tr1 function templates used to store a function that handles the event.

I created a vector so

7条回答
  •  再見小時候
    2020-12-07 03:14

    The proposal (section IIIb.) states they will not be comparable in any way. If you attach some extra information to them, you can easily identify each callback. For instance, if you simply define a struct wrapping the function pointer, you can remove them (assuming you have the same struct you inserted). You can also add some fields to the struct (like an automatically generated guid the client can hold on to) and compare against that.

提交回复
热议问题