dim*_*mba 17 c++ stl namespaces
我希望在示例中,bellow编译器将无法编译代码,因为它不知道什么是"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
}
Run Code Online (Sandbox Code Playgroud)
Bjö*_*lex 27
这适用于Argument Dependent Lookup.在参数类型的命名空间中搜索函数模板.在这种情况下,参数是std::string::iterator,因此在命名空间中搜索函数std.
| 归档时间: |
|
| 查看次数: |
439 次 |
| 最近记录: |