为什么不超载计数 [英] why not overload count

查看:68
本文介绍了为什么不超载计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在STL中具有count()和count_if(),为什么不像next_find()那样重载count()函数呢?谢谢!

we have count() and count_if() in STL, why not just overload the count() function like adjacent_find() does? Thanks!

推荐答案

区别在于countcount_if具有相同数量的参数(3),而adjacent_find具有2个参数,非参数谓词版本vs谓词1中的3.

当然,对于非模板函数或模板概念(从C ++ 0x投票和删除)来说,这都不是问题,但是对于C ++函数模板的当前实现,这是一个问题.
The difference is that count and count_if have the same number of parameters (3) and adjacent_find has 2 parameters in the non-predicate version vs 3 in the predicate one.

Of course, that wouldn''t be a problem with non-template functions, or with template concepts (voted and removed from C++ 0x), but with the current implementation of C++ function templates it is.


这篇关于为什么不超载计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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