STL 算法函数名称解析
STL algorithm function name resolution
我希望在下面的示例中,下面的编译器将无法编译代码,因为它不知道什么是"find()",它在算法标头的 std 命名空间中定义。
但是,此代码在带有 gcc 4.1.2 的 RHEL 5.3 上编译。
我错过了什么?
#include <string>
#include <algorithm>
int main()
{
std::string s;
find(s.begin(), s.end(), 'a'); // should not compile
}
由于参数依赖查找,这有效。在参数类型的命名空间中搜索函数模板。在这种情况下,参数std::string::iterator
,因此在命名空间std
中搜索函数。
相关文章:
- 为什么这个运算符<重载函数对 STL 算法不可见?
- STL算法函数在多个一维容器上的使用
- A*算法中魔方的启发式函数 人工智能
- 使用指针算法修改函数中的 2D 数组
- 如何将 c++ get 函数代码转换为 opencv 算法中使用的 python
- 如何在算法中使用谓词函数find_if?
- 我们如何并行运行算法的 n 个实例并以有效的方式计算结果函数的平均值?
- 如何在复杂的算法中处理goto函数?
- 快速排序函数在快速排序算法中如何工作?
- 在 c++ 或 python 中生成一个体面的视差图以在 Raspberry Pi 上实现的最佳方法(算法或函数)是什么
- 阴算法(音高检测) - 差分函数的替代
- 算法中的排序函数返回错误
- 如何处理算法中具有不同名称成员函数的类?
- STL算法函数,如累加,如果传递给它们的函数接受引用,请避免复制
- 欧几里得算法函数参数
- STL 算法函数模板
- 为什么我必须始终在 STL 的算法函数中显式指定范围,即使我想处理整个容器?
- 算法函数:将其作为模板或采用std::function参数
- 为std算法函数创建一个包装器,用容器代替迭代器
- STL 算法函数名称解析