C++:为什么 std::greater<T>() 包含在 iostream 中?
C++: Why is std::greater<T>() included in iostream?
我注意到我的C++包含std::greater<T>()
代码编译得很好,而不包含<functional>
。这引起了我的思考。事实证明,这段代码编译:
#include <iostream>
int main(){
std::greater<T>();
}
但这个没有:
int main(){ //<iostream> doesn´t get included
std::greater<T>();
}
通过它,我可以推断<iostream>
包含std::greater
这对我来说似乎有些奇怪。有人可以解释一下,为什么std::greater<T>()
包含在<iostream>
中?
如果这很重要,我正在使用 g++(x86_64-posix-she-rev0,由 MinGW-W64 项目构建(8.1.0 和 C++14。
ISO标准不能保证。该标头的实现使用它。 您可能还会发现<utility>
、<string>
(可能作为<ios>
或<iosfwd>
的一部分包含在内(、<memory>
和一些<type_traits>
可以从<iostream>
获得。
五个保证的标头是(自C++11以来(:ios,iosfwd,istream,ostream,streambuf。
相关文章:
- 包含在 <initializer_list> <iostream>?
- 为什么在包含iostream时可以使用printf()?
- 为什么我必须在包含后写 std::cin <iostream>?
- 包含iostream导致不同的二进制文件
- C++ Boost-iostream:包含 filtering_streambuf.hpp 时出现神秘错误
- C++:为什么 std::greater<T>() 包含在 iostream 中?
- 包含<iostream>时"Undefined reference"错误
- 通过包含<iostream>头文件,它的所有 8 个函数是写入我的代码,还是只写入我在程序中使用的函数?
- 为什么包含iostream时此代码更快?
- 包含iostream时的自定义类时间的错误实例
- 运算符== 如果我包含<iostream>,则不编译
- 为什么我会得到一个包含<iostream.h>?
- 为什么 Xcode 4 在每个标头中都包含 iostream
- 已安装 Cygwin64,但在<iostream>日食中找不到未解析的包含内容
- 为什么同时包含<iostream>和<fstream>
- 在 Xcode 中,当我包含 <iostream>时,似乎 stdlib.h 也被包含。为什么?
- 不能包含iostream (VS2010)
- C++断言在我包含 iostream 标头时不会产生堆栈帧
- 为什么只包含iostream.h会使可执行文件的重量增加1mb
- 包含iostream和包含iostream.h有什么区别