没有函数式编译的 C++ 程序 header
C++ program compiling without functional header
根据 CPP Doc,std::greater
在 <functional>
header 中定义,但我使用 std::greater
的 C++ 程序正在使用 TDM-GCC- 64 5.1.0 和 运行 只有以下内容包括:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
可能是因为 <algorithm>
自动包含 <functional>
但由于文档中没有提到这一点,我想知道有没有办法事先知道这一点?
为了结束这个话题,结论是这取决于实现,所有必要的 headers 都应该包括在内以实现可移植性。
根据 CPP Doc,std::greater
在 <functional>
header 中定义,但我使用 std::greater
的 C++ 程序正在使用 TDM-GCC- 64 5.1.0 和 运行 只有以下内容包括:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
可能是因为 <algorithm>
自动包含 <functional>
但由于文档中没有提到这一点,我想知道有没有办法事先知道这一点?
为了结束这个话题,结论是这取决于实现,所有必要的 headers 都应该包括在内以实现可移植性。