C ++中的谓词是什么? [英] What is predicate in C++?

查看:501
本文介绍了C ++中的谓词是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

谓词是一个C ++函数,返回布尔值或实例对象有bool operator()成员。
一元谓词需要一个agrument,binary-two等。
问题谓词的示例可以回答一个特定的算法:




  • 这是我们正在寻找的元素吗?

  • 两个参数中的第一个以我们的顺序排列。

  • 参数等于?



几乎所有 STL算法将谓词作为最后一个参数。



您可以使用标准,自己的和谓词创建类来构造新的谓词(这里是一个很好的参考资料)。


Can you give some example or a link to a topic.

解决方案

Predicate is a C++ function returning boolean or instance of object having bool operator() member. Unary predicate take one agrument, binary - two, etc. Examples of questions predicates can answer for a particular algorithm are:

  • Is this element what we are looking for?
  • Is the first of two arguments ordered first in our order?
  • Are the two arguments equal?

Almost all STL algorithms take predicate as last argument.

You can construct new predicates using standard, your own and predicate-making classes (here is a good reference).

这篇关于C ++中的谓词是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆