g++抱怨STD功能
g++ complaining about STD functions
我有一段下载的源代码,当试图使用g++编译器通过Cygwin进行编译时,编译器给了我一个错误,说"transform"函数在此范围内未声明。。。
我使用的是std名称空间,并且我有正确的标题。我不知道为什么它没有编译。。语法看起来正确
这是代码块部分。
string tolower (const string & s)
{
string d = s;
transform(d.begin(), d.end(), d.begin(), (int(*)(int)) tolower);
return d;
} // end of tolower
这是我的标题部分:
#include <fcntl.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
// standard library includes ...
#include <string>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stdexcept>
#include <fstream>
#include <iostream>
#include <sstream>
#include <ios>
#include <iterator>
using namespace std;
您需要为std::transform
:包含适当的标头
#include <algorithm>
您还应该避免在头文件的全局命名空间中使用using namespace std;
,这会污染包括头文件在内的任何代码的全局命名空间。
请参阅这篇关于using namespace std
的文章。
相关文章:
- 我应该实现右值推送功能吗?我应该使用std::move吗
- std::is_trivially_copyable_v 关于虚拟功能
- 字符转换功能 std::isupper() & std::islower() C++17
- 错误:在尝试检测 std::cout 是否<< t 时,功能强制转换为数组类型;有效
- 使用 std::call_once 实现类似单例的功能
- Cuda 基本程序 (将值写入矩阵和 std:cout 不起作用) ;主功能不启动
- C++ std::enable_if - 第二个参数的功能
- 如何使用 GDB 从功能C++逐步调试到 std::function 用户代码?
- 无法从好友功能访问类的私有成员?"ostream"不是"std"的成员?
- C++11 功能 std::map::at 编译旧版本的C++
- Boost Variant 是否提供与 std holds_alternative类似的功能?
- 我有模板功能.通过使用函数std::for_each,用这个容器中的最大数字替换每个正数
- 如何将标准::矢量插入具有自定义排序功能的 std::set 中
- 是否有可能通过演绎指南实现整个 std::make_tuple 功能?
- std ::功能作为默认参数的功能
- C 中STD :: vector的压实bool功能
- 如何在不接触函数本身的情况下暂停和恢复 C++11 std::thread 的功能
- 复制std ::功能多么昂贵
- 不存在从"const std::string"到"time_t"的合适转换功能
- 使用已删除的功能'std::thread::thread(const std::thread&)'