VS 是不支持 万能头的,需要我们自己去手动添加。
原理
首先我们得知道万能头是个啥东西。(其实是我不知道。。QAQ)
<bits/stdc++.h>
其实就是一个头文件,里面包含了几乎所有的C++库里的头文件。
因此一般只需要包含这一个头文件就能满足所有的需求。
不过自然也会有着一些缺点。
优点
- 简单便捷。能满足大多数场合,即一些对运行需求不大严格的场合。
- 节省时间,不必考虑需要加入哪些头文件。这对参与竞赛的时候能起到一点帮助。
缺点
- 包含所有的头文件,编译时速度自然就稍慢一些,增加编译时间。
- 这不是C++的标准库,因而不是所有的编译系统都有,比如一些OJ就可能没有。
- 不建议新手使用,新手还是要多用用库文件,才知道那些标准库里都有啥。
VS添加<bits/stdc++.h>
首先我们需要新建一个文件夹bits
,然后创建一个头文件stdc++.h
。
头文件内容即是万能头里的实质内容。
文件内容
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2017 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
// <http://www.gnu.org/licenses/>.
/** @file stdc++.h
* This is an implementation file for a precompiled header.
*/
// 17.4.1.2 Headers
// C
#ifndef _GLIBCXX_NO_ASSER