点击蓝字

关注我们

C++ 中万能头文件 bits/stdc++.h 的介绍

很多小伙伴估计看有的代码会碰见没有多余的其它头文件比如 algorithm、cmath、iostream 而是用了一行 #include<bits/stdc++.h> 这样的头文件并感到诧异,想这是什么。

其实这是一个包含了 C++ 所有头文件的一个头文件,为了方便而发明的,其中包含了一下头文件

//c
#ifndef _GLIBCXX_NO_ASSERT
#include<cassert>
#endif
#include<cctype>
#include<cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

谈一下朋友们担心的兼容性问题,一早起来跑了几个oj亲测兼容性还是蛮强的,看到去年的介绍博客表示hdu不支持不过现在亲测已经支持了,请在hdu肆无忌惮的开挂吧!!

当然国外的主流oj,台湾的oj,Codeforces和Topcoder这些去年就已经支持#include<bits/stdc++.h> 的oj如今也依旧支持。

看了别人对于这个头文件的看法,自己也有了更深的认识,包含大量不需要的库的头文件,更适合在oj比赛中使用。如果在软件工程的开发中,我们应该减少包含,控制编译时间和代码大小。

优点如下:

1.在竞赛中节约时间

    2.减少了编写所有必要头文件的工作量

    3.对于使用的每个函数,不用记住GNU C++的所有STL

缺点如下:

    1.不属于GNU C++库的标准头文件,在部分情况下可能会失败

    2.使用它将包含许多不必要的东西,并增加编译时间

    3.这个头文件不是C++标准的一部分,因此是不可移植的,应该避免

    4.编译器每次编译翻译单元时都必须实际读取和分析每个包含的头文件,应该减少这类头文件的使用

*声明:本文于网络整理,版权归原作者所有,如来源信息有误或侵犯权益,请联系我们删除或授权事宜。

戳“阅读原文”我们一起进步

C++ 的万能头文件,你知道多少?相关推荐

  1. 万能头文件#include<bits/stdc++.h>更新GCC10.2.0版本

    C++标准库里的万能头文件:#include<bits/stdc++.h> 可用于各大Online Judge测试平台(POJ除外,这些年不维护更新了) 由于网上的都是2014年版的万能头 ...

  2. c++万能头文件_初学Python,与C对比

    ✎背景学了一学年的C的基础,下学年开课Python,现在正在自学中...C也不是不学了,而是之前买了一本<C++Primer>在学校里,就准备先学一下Python,下学期利用自由时间接着学 ...

  3. VScode找不到C++万能头文件<bits/stdc++.h>解决办法

    VScode找不到C++万能头文件<bits/stdc++.h>解决办法 一.万能头文件介绍 万能头文件<bits/stdc++> 中包含了 C++中大部分头文件,在大部分做题 ...

  4. MAC OS下设置bits/stdc++.h万能头文件

    在MAC下用atom写c++程序时用到万能头文件会比较方便. 准备: 下载xcode或者command line developer tools 地址:https://developer.apple. ...

  5. Visual Studio 中使用万能头文件 #include bits/stdc++.h

    进行各种练习赛后,看题解代码时经常会看到这么一个陌生的头文件 #include <bits/stdc++.h> ,这个头文件是一个C++万能头文件,里面包含了程序比赛中所有可能用到的头文件 ...

  6. Visual Studio 中使用万能头文件 #include <bits/stdc++.h>

    Visual Studio 中使用万能头文件 #include 前言 最近开始使用VS,之前用的DEV C++软件可直接使用 #include <bits/stdc++.h> ,但VS中并 ...

  7. macOS使用C/C++万能头文件保姆级教程

    macOS使用C/C++万能头文件保姆级教程 Windows上面用万能头文件为我们省去了不少记头文件的麻烦,切换到macOS上来发现C/C++环境中没有自带这个头文件.不行,今天无论如何都要用到万能头 ...

  8. VScode添加C++万能头文件

    VScode添加C++万能头文件 参考:vscode编译器添加c++万能头文件 使用xcode以及vscode时需要自行添加万能头才可以在代码中使用. 本质都是找到软件中储存库函数的文件夹中再添加一个 ...

  9. 【C++】万能头文件 <bits/stdc++.h> 的用法和优缺点

    [C++]万能头文件 bits/stdc++.h 的用法和优缺点 文章目录 [C++]万能头文件 bits/stdc++.h 的用法和优缺点 一.使用方法 二.头文件的内容 三.VS 中如何使用 四. ...

  10. C++万能头文件(bits/stdc++.h)

    先说一句 C++万能头文件,并不是所有场合都能用,比如说POJ. 我曾在POJ提交过程序,编译错误.就是因为用了万能头文件. 意思就是,不认识<bits/stdc++.h>. 因为,万能头 ...

最新文章

  1. pcb怎么画边框_关于PCB焊盘,你了解多少?
  2. linux epoll模型
  3. (022)java后台开发之HttpServletRequest
  4. RHEL6 64bit下更改YUM配置。yum this system is not registered with rhn的解决办法
  5. 今天痛下决心,把开发人员的外网给断了,不断是不好管了,人心散了队伍就不好带...
  6. msc货物跟踪查询_运联研究 | 货物全程可视,能否真正消除物流信息盲点?
  7. linux malloc 线程,Linux上的侧线程的malloc/calloc崩溃
  8. 第三次学JAVA再学不好就吃翔(part57)--StringBuffer和String的相互转换
  9. idea中drl文件_得分DRL:在OptaPlanner中更快,更轻松
  10. 版本不见了_王者荣耀复古版本来袭?第四代主宰形象回归!可以给小兵加速
  11. React 组件的生命周期详解
  12. Python调用Java代码部署及初步使用
  13. ios Photos框架
  14. web.xml 模板和Servlet版本
  15. VSCode : vscode-remote下无法写入文件及linux文件读写权限
  16. java dem数据格式解析_ArcGIS读取dem格式数据
  17. mysql注入单引号和双引号的区别_mysql单引号和双引号的用法
  18. android 服务检测,Android检测某个服务是否还活着代码
  19. ADT: Graph 图
  20. thinkpad T450 重新安装系统 win 10

热门文章

  1. 《Shell脚本学习指南》学习笔记
  2. 史上最详细的F450四轴装机实例(无名官方推荐的)
  3. Delphi7·ProgressBar控件
  4. Mac电脑常用软件安装
  5. 不知为不知--信息论和最大熵原则
  6. Visual Studio Code 取色器插件 取色选取 插件安装和使用
  7. java 学生成绩管理系统_学生成绩管理系统
  8. 【数学建模】传染病SIR模型
  9. 推荐一款专业串烧歌曲的音乐合并软件
  10. stata软件meta分析模块安装教程