서의 공간

C++ Standard Library (표준 라이브러리) 본문

C++/Syntax, Features

C++ Standard Library (표준 라이브러리)

홍서의 2020. 11. 27. 05:51

[C++ 표준라이브러리 참조 MSDN]: C++ Standard Library Reference | Microsoft Docs

 

카테고리 헤더
알고리즘 <algorithm>, <cstdlib>, <numeric>
아토믹 연산 <atomic>
C 라이브러리 래퍼 <cassert>, <ccomplex>, <cctype>, <cerrno>, <cfenv>, <cfloat>, <cinttypes>, <ciso646>, <climits>, <clocale>, <cmath>, <csetjmp>, <csignal>, <cstdalign>,
<cstdarg>, <cstdbool>, <cstddef>, <cstdint>, <cstdio>, <cstdlib>, <cstring>, <ctgmath>, <ctime>, <cuchar>, <cwchar>, <cwctype>, <ccomplex>
개념 <concepts>
컨테이너  
시퀀스 컨테이너 <array>, <deque>, <forward_list>, <list>, <vector>
정렬된 연관 컨테이너 <map>, <set>
정렬되지 않은 연관 컨테이너 <unordered_map>, <unordered_set>
컨테이너 어댑터 <queue>, <stack>
컨테이너 뷰 <span>
오류 및 예외 처리 <cassert>, <exception>, <stdexcept>, <system_error>
일반 유틸리티 <any>, <bit>, <bitset>, <cstdlib>, <execution>, <functional>, <memory>,
<memory_resource>
, <optional>, <ratio>, <scoped_allocator>,
<tuple>, <type_traits>, <typeindex>, <utility>, <variant>
I/o 및 서식 지정 <cinttypes>, <cstdio>, <filesystem>, <fstream>,<iomanip>, <ios>, <iosfwd>, <iostream>, <istream>, <ostream>, <sstream>,
<streambuf>, <strstream>, <syncstream>
반복기 <iterator>
언어 지원 <cfloat>, <climits>, <codecvt>, <compare>, <contract>, <coroutine>,
<csetjmp>, <csignal>, <cstdarg>, <cstddef>, <cstdint>, <cstdlib>,
<exception>, <initializer_list>, <limits>,<new>, <typeinfo>, <version>
지역화 <clocale>, <codecvt>, <cvt/wbuffer>, <cvt/wstring>, <locale>
수학 및 숫자 <bit>, <cfenv>, <cmath>, <complex>, <cstdlib>, <limits>, <numeric>,<random>, <ratio>, <valarray>
메모리 관리 <allocators>, <memory>, <memory_resource>, <new>, <scoped_allocator>
다중 스레딩 <atomic>, <condition_variable>, <future>, <mutex>,<shared_mutex>, <thread>
범위 <ranges>
정규식 <regex>
문자열 및 문자 데이터 <charconv>, <cctype>, <cstdlib>, <cstring>, <cuchar>,<cwchar>, <cwctype>, <regex>, <string>, <string_view>
시간 <chrono>, <ctime>

 

C++ 표준 라이브러리는 총 80개의 헤더 파일로 구성되어 있고, 그중 26개는 C 표준 라이브러리를 위한 것이다. 다음 자료는 각 헤더 파일의 내용을 다음과 같이 8개의 범주로 나누어 간략하게 기술한다.

  • C 표준 라이브러리
  • 컨테이너
  • 알고리즘, 반복자, 할당자
  • 일반 유틸리티
  • 수학 유틸리티
  • 익셉션
  • I/O 스트림
  • 스레딩 라이브러리

1. C 표준 라이브러리

C++ 표준 라이브러리는 C 표준 라이브러리 전체를 포함하고 있다. 헤더 파일도 일반적으로 같지만 두 가지 점에서 차이가 있다.

  • 헤더 파일 이름이 예를 들어 <name.h> 대신 <cname>이다.
  • <cname> 헤더 파일 안에 정의된 모든 이름은 std 네임스페이스에 속한다.

다음 표는 가장 유요한 헤더 파일과 기능을 요약한 것이다.

헤더 파일명 내용
<cassert> assert() 매크로
<ccomplex> 복소수 관련 유틸리티
<cctype> isspace(), tolower() 같은 문자 프레디킷과 매니퓰레이터 함수
<cerrno> errno 표현 정의. C 언어의 함수에서 발생한 마지막 에러 코드를 얻는 매크로.
<cfenv> 부동소수점 관련 익셉션, 올림, 반올림, 버림 등을 정의
<cfloat> FLT_MAX 등과 같은 부동소수점 관련 C 스타일 산술 연산 정의
<cinttypes> printf(), scanf() 같은 함수에서 사용되는 여러 매크로를 정의. intmax_t를 이용하는 함수들도 포함
<ciso646> C에서는 <iso646.h> 파일이 매크로 and, or 등을 정의한다. <ciso646>에는 C++ 키워드와 충돌되는 것들은 포함되어 있지 않다.
<climits> INT_MAX 등 C 스타일 limt 정의
<clocale>  LC_ALL과 setlocale() 같은 몇 가지 로컬라이제이션 매크로와 함수 정의
<cmath> 삼각함수, sqrt(), fabs() 등 수학 유틸리티
<csetjmp> setjmp()와 longjmp(). C++에서는 절대 사용하지 않는다.
<csignal> signal()과 raise(). C++에서는 가능한 한 사용하지 않는다.
<cstdalign> __alignas_is_defined와 같은 얼라인먼트 관련 매크로
<cstdarg> 가변 인자 목록을 처리하기 위한 매크로와 타입들
<cstdbool> __bool_true_false_are_defined와 같은 불 타입 관련 매크로
<cstddef> NULL, size_t와 같은 중요 상수와 타입
<cstdint> int8_t, int64_t와 같은 표준 정수 타입 정의와 각 타입별 최솟값, 최댓값에 대한 매크로
<cstdio> fopen()과 fclose() 같은 파일 작업, fseek()과 ftell() 같은 파일 위치 이동, printf()와 scanf() 같은 포매팅된 입출력, getc()와 putc() 같은 문자 입출력.
<cstdlib> 난수 생성을 위한 rand()와 srand() 함수. abort()와 exit() 함수(C++에서는 사용을 피해야 한다). calloc(), realloc(), free() 같은 C 스타일 메모리 할당 함수. qsort()와 bsearch() 같은 C 스타일 정렬과 검색 함수. atof(), atoi()와 같이 문자열을 숫자로 변환하는 함수. 멀티바이트/와이드 문자열 조작과 관련된 함수.
<cstring> memcpy()와 memset() 등 저수준 메모리 관리 함수, strcpy()와 strcmp() 같은 C 스타일 문자열 처리 함수
<ctgmath> <ccomplex>와 <cmath>를 인클루트
<ctime> time()과 localtime() 같은 시간 관련 함수
<cuchar> mbrtoc16() 등 유니코드 관련 매크로와 함수
<cwchar> 와이드 문자를 위한 여러 버전의 문자열, 메모리, I/O 관련 함수
<cwctype> iswspace(), towlower() 등 <cctype>에 정의된 함수들의 와이드 문자 버전

 

2. 컨테이너

헤더 파일명 내용
<array> array 클래스 템플릿
<bitset> bitset 클래스 템플릿
<deque> deque 클래스 템플릿
<forward_list> forward_list 클래스 템플릿
<list> list 클래스 템플릿
<map> map과 multimap 클래스 템플릿
<queue> queue와 priority_queue 클래스 템플릿
<set> set과 multiset 클래스 템플릿
<stack> stack 클래스 템플릿
<unordered_map> unordered_map과 unordered_multimap 클래스 템플릿
<unordered_set> unordered_set과 unordered_multiset 클래스 템플릿
<vector> vector와 vector<bool> 클래스 템플릿

 

3. 알고리즘, 반복자, 할당자

헤더 파일명 내용
<algorithm> 대부분의 STL 알고리즘 프로토타입이 정의되어 있다.
<functional> negator, binder, adaptor 등 내장 함수 객체들의 정의
<iterator> iterator_traits. 반복자 태그, iterator, reverse_iterater, 삽입 반복자(back_inserter 등), 스트림 반복자의 정의.
<memory> 디폴트 할당자, 초기화되지 않은 컨테이너 항목을 위한 유틸리티 함수, C++11에서 소개한 unique_ptr, shared_ptr, make_unique(), make_shared() 스마트 포인터 템플릿 클래스 정의
<numeric> accumulate(), inner_product(), partial_sum(), adjacent_difference() 등 몇 가지 수치 연산 알고리즘의 프로토타입 정의
<scoped_allocator> string의 vector 또는 map의 vector와 같이 중첩된 컨테이너에서 사용할 수 있는 할당자

 

4. 일반 유틸리티

헤더 파일명 내용
<chrono> 크로노 라이브러리 정의.
<codecvt> 여러 가지 문자열 인코딩 코드 변환을 위한 패싯(facet)
<initializer_list> initializer_list 클래스 정의.
<limits> numeric_limits 클래스 템플릿과 내장 타입의 특수화 정의.
<locale> locale 클래스, use_facet(), has_facet() 템플릿 함수, 그리고 여러 가지 facet 관련 정의.
<new> bad_alloc 익셉션과 set_new_handler() 함수 정의. operator new와 operator delete의 6가지 프로토타입 정의.
<random> 난수 생성 라이브러리 정의.
<ratio> 컴파일 타임 유리수 연산을 위한 유리수 라이브러리 정의.
<regex> 정규 표현식 라이브러리 정의.
<string> basic_string 템플릿 클래스와 인스턴스화된 string, wstring의 typedef
<system_error> 에러 카테고리와 에러 코드 정의
<tuple> pair 템플릿 클래스의 일반화 버전인 tuple 템플릿 클래스 정의.
<type_traits> 템플릿 메타프로그래밍을 위한 타입 트레이츠 정의.
<typeindex> 연관 컨테이너와 비순차 연관 컨테이너에서 인덱스 타입으로 이용될 수 있는 type_info에 대한 단순한 래퍼 정의
<typeinfo> bad_cast와 bad_typeid 익셉션 정의. typeid 연산자에 의해 리턴되는 type_info 객체의 클래스 정의.
<utility> pair 템플릿 클래스 정의.

 

5. 수학 유틸리티

헤더 파일명 내용
<complex> 복소수 연산을 위한 complex 템플릿 클래스 정의
<valarray> 벡터와 행렬 수학 연산을 위한 valarray 및 관련 클래스/템플릿 클래스 정의

 

6. 익셉션

헤더 파일명 내용
<exception> exception과 bad_exception 클래스, set_unexpected(), set_terminate(), uncaught_exception() 함수 정의
<stdexcept> <exception>에 정의되어 있지 않은 특정 기능에 종속되지 않는 일반 익셉션 정의

 

7. I/O 스트림

헤더 파일명 내용
<fstream> basic_filebuf, basic_ifstream, basic_ofstream, basic_fstream 클래스의 정의와 filebuf, wfilebuf, ifstream, wifstream, ofstream, wofstream, fstream, wfstream에 대한 typedef 선언
<iomanip> 다른 헤더 파일에 정의되어 있지 않은 I/O 매니퓰레이터 선언(대부분 <ios>에 정의됨)
<ios> ios_base와 basic_ios 클래스의 정의. 대부분의 스트림 매니퓰레이터에 대한 선언. 이 헤더 파일을 직접 인클루드해야 할 경우는 드물다.
<iosfwd> I/O 스트림 헤더 파일에서 사용되는 템플릿과 typedef의 포워드 선언. 이 헤더 파일을 직접 인클루드해야 할 경우는 드물다.
<iostream> cin, cout, cerr, clog 및 이들의 와이드 문자 버전의 선언. 이 헤더 파일은 단순히 <istream>과 <ostream>을 합친 것이 아님에 주의한다.
<istream> basic_istream과 basic_iostream 클래스 정의. istream, wistream, iostream, wiostream에 대한 typedef 선언
<ostream> basic_ostream 클래스 정의. ostream과 wostream에 대한 typedef 선언
<sstream> basic_stringbuf, basic_istringstream, basic_osringstream, basic_stringstream 클래스에 대한 정의. stringbuf, wstringbuf, istringstream, wistringstream, ostringstream, wostringstream, stringstream, wstringstream에 대한 typedef 선언
<streambuf> basic_streambuf 클래스 정의. streambuf와 wstreambuf에 대한 typedef 선언. 헤더 파일을 직접 인클루드해야 할 경우는 드물다.

 

8. 스레딩 라이브러리

헤더 파일명 내용
<atomic> 아토믹 타입, atomic<T>, 아토믹 작업 정의
<condition_variable> condition_variable과 condition_variable_any 클래스 정의
<future> future, promise, packaged_task, async() 정의
<mutex> 여러 가지 mutex, lock 클래스 및 call_once() 정의. 단, shared_timed_mutex와 shared_lock은 빠져 있다.
<shared_mutex> shared_timed_mutex와 shared_lock 클래스 정의
<thread> thread 클래스 정의

'C++ > Syntax, Features' 카테고리의 다른 글

C++ 복사 생성자와 임시 객체  (0) 2020.12.13
C++ 템플릿  (0) 2020.11.27
C++ 키워드  (0) 2020.11.27
C++ STL(Standard Template Library)  (0) 2020.11.27
Comments