C++中万能头文件的介绍及它的利弊。

-----正文开始------

0 什么是头文件

头文件其实就是一些函数,运用头文件可以让你在程序中使用这些函数,也就是STL。

1什么是万能头文件

万能头文件是一个c++中包含所有常用头文件的一个头文件。

#include<bits/stdc++.h>

2 万能头文件的好处:

万能头文件可以使你的程序变得简洁。比如以下代码:

#include<iostream>
#include<set>
#include<string>
#include<map>
#include<vector>
#include<queue>
...

使用万能头以后:

#include<bits/stdc++.h>

是不是心情好很多了?

3 万能头文件的劣处

1 程序会变慢

头文件是STL的集合,用了万能头文件会让程序吧所有STL都运行一遍(假如你家境贫寒,电脑为I9-100900K+64GB RAM,当我没说)。

2 部分编译器不支持

万能头文件为“ bits/stdc++.h“”里面有‘/’,它不是c++标准库里的头文件。。。(比如MSVC就不支持万能头)

3人会变懒

附件:万能头代码:

// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2014 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_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

0 0 vote
Article Rating
Subscribe
提醒
12 评论
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Yuq Huang

应该是i910900K
然而我觉得i910980XE更豪气

23786 蘑菇蘑菇蘑菇蘑

Mac Pro用户:假如你家境贫寒,电脑为Intel Xeon 28核+1.5TB RAM,当我没说

Last edited 2 月 之前 by 23786 蘑菇蘑菇蘑菇蘑
EricNTH

阿呀呀也就五十万嘛。挺便宜

23786 蘑菇蘑菇蘑菇蘑

不喜欢万能头文件。感觉是低级的人用的。Mac上也不能用。

EricNTH

同感

Rolling_Code

大佬大佬!
Orz

Ryan Jiang

噗。

qyh

没有正文???

23786 蘑菇蘑菇蘑菇蘑

没写完

12
0
Would love your thoughts, please comment.x
()
x