原文地址: 【C++】头文件 bits/stdc++.h 是啥?
欢迎访问我的博客:http://blog.duhbb.com/
嘿嘿, 以后写 leetcode 的话, 本地直接就引用这个文件, 还是很方便的;但是由于不可移植以增加编译时间等, 墙裂建议不要在生产环境使用.
引言最近看别人的 C++ 代码, 发现了这么一个头文件:
#include
然后我就有点奇怪了, 以前好像没有遇到过呀, 然后这个 C++ 头文件也比较特别, 是以 .h 结尾的, 于是乎打算一探究竟.
它是 C++ 中支持的一个几乎万能的头文件, 几乎包含所有的可用到的 C++ 库函数. 以后写代码就可以直接引用这一个头文件了, 不需要在写一大堆 vector, string, map, stack 等等
使用方法#include头文件的内容int main() { // write code here return 0 }
// C++ includes used for precompiling -*- C++ -*- // Copyright (C) 2003-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see //优点与缺点. // 17.4.1.2 Headers // C #ifndef _GLIBCXX_NO_ASSERT #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __cplusplus >= 201103L #include #include #include #include #include #include #include #include #include #endif // C++ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include
#include
来源: bits/stdc++.h in C++
bits/stdc++ 的缺点- bits/stdc++.h 是 GNU C++ 库的非标准头文件. 因此, 如果您尝试使用 GCC 以外的其他编译器编译代码, 它可能会失败;例如,MSVC 没有此标头.
- 使用它会包含很多不必要的东西并增加编译时间.
- 此头文件不是 C++ 标准的一部分, 因此不可移植, 应避免使用.
- 此外, 即使标准中有一些包罗万象的标头, 您也希望避免使用它来代替特定标头, 因为编译器必须每次都实际读取并解析每个包含的标头 (包括递归包含的标头) 编译单元.
- 在比赛中, 当你想减少浪费在做家务上的时间时, 使用这个文件是个好主意;尤其是当您的排名对时间敏感时.
- 这也减少了编写所有必要的头文件的所有琐事.
- 您不必为使用的每个函数记住所有 GNU C++ 的 STL.
原文地址: 【C++】头文件 bits/stdc++.h 是啥?
欢迎访问我的博客:http://blog.duhbb.com/



