具有全局符号的命名为STD符号Interfier
Namespaced std symbol interfiers with a global symbol
使用此全局名称空间find((模板函数:
#include <iostream>
#include <vector>
template <typename Iterator, typename T>
Iterator find(Iterator first, Iterator last, T value) {
while(first!=last && *first!=value)
++first;
return first;
}
int main(int argc, const char * argv[]) {
std::vector<int> v = {1,3,5,7};
std::vector<int>::iterator pos = find(begin(v), end(v), 3);
if (pos != end(v))
std::cout << "Foundn";
return 0;
}
为什么,编译器(clang(失败,表明有两个候选模板函数:我的find((和标准std :: find((?
这是由于参数依赖性查找(adl(。
要避免通过ADL,请写下:
std::vector<int>::iterator pos = ::find(begin(v), end(v), 3);
而不是。
相关文章:
- 将无符号char*转换为std::istream*C++
- 在 std::无符号字符的向量处存储 int 的十六进制表示形式
- 从 std::vector<无符号字符>切片中提取 int?
- 将无符号字符的向量存储在数组中会给我 std::bad_alloc
- 无法从 std::string 中提取C++ Unicode 符号
- 未定义的引用,尽管存在符号,但 std::experimental::可选
- 体系结构x86_64的未定义符号:std:terminate(),typeinfo,运算符delete[],运算符new
- 如何打印大于"无符号长长"的"std::bitset"的十进制值?
- 如何将带有十六进制值的 std::string 转换为 std::vector<无符号字符>
- 在 c++ 中以十六进制格式打印无符号字符(BYTE).使用 std::cout
- 如何在 qi 符号表中使用 std::function
- 在 std::vector<无符号字符中存储任意数据的方法>
- C++ std::vector<int> 体系结构的未定义符号 x86_64:
- 从 std::string 转换为 const 无符号整数
- 如何使用 std::copy 当类有"无符号字符和运算符[]"时
- C++ C4244 =':从"std::streamsize"转换为"无符号短",可能会丢失数据;有什么解决办法吗?
- LNK2001:未解析的外部符号public:static类std::vector
- 编译了一个recent-C++.因此,如果没有暴露std符号,请在旧系统上运行
- 为什么 std:: 符号在共享库中被强制导出?
- 是否有 GCC 警告,用于使用 C 库中的符号而不是通过命名空间 std?