简体   繁体   English

检查两个std :: function是否相等

[英]Check if two std::function are Equal

If I have two std::function s, how can I check whether both hold the same function or not? 如果我有两个std::function ,如何检查它们是否都具有相同的功能?

Additional Information: I have a vector of functions std::vector<std::function<void()>> and before adding another function to the vector I want to check if it already is contained. 附加信息:我有一个向量std::vector<std::function<void()>>的向量,在向该向量添加另一个函数之前,我想检查它是否已包含。

I dont think that they both can be compared. 我认为他们两者都无法比较。 Here is an example to explain some points on std::function comparison 这是一个解释std :: function比较中一些要点的示例

通常std::functionboost::function是不可比较的,因为它们需要它们的存储对象是可比较的,但并非所有功能对象都一样,而且lambda都具有operator==因此stdboost函数无法对其进行比较

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM