Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C++

Standard Library (Thư viện chuẩn) trong C++

C++ Standard Library** là tập hợp class và function viết bằng core language, là một phần của chuẩn C++ ISO. Cung cấp: generic containers, hàm thao tác container, function objects, string/stream (I/O file/interactive), hỗ trợ tính năng ngôn ngữ, hàm tiện ích hàng ngày (ví dụ: căn bậc hai).

Các thành phần chính

Nhóm Header ví dụ Mô tả
Streams (I/O) <iostream>, <fstream>, <sstream>, <iomanip> Console, file, string stream, format I/O
Containers <vector>, <map>, <set>, <queue>, <stack>, <array> Lưu trữ dữ liệu (thành phần STL)
Algorithms <algorithm>, <numeric> sort, find, transform, accumulate...
Strings <string>, <string_view> (C++17) std::string, string_view
Utilities <utility>, <memory>, <functional>, <tuple>, <optional>, <variant>, <any> pair, smart pointer, function wrapper, tuple, sum types
Numerics <complex>, <random>, <valarray>, <cmath> Số phức, random, toán học
Concurrency <thread>, <mutex>, <atomic>, <future>, <shared_mutex>, <semaphore> (C++20) Thread, sync, atomic, async
Filesystem <filesystem> (C++17) Thao tác file/thư mục portable
Regex <regex> (C++11) Biểu thức chính quy
C Standard Library <cstdio>, <cstdlib>, <cstring>, <ctime>, <cmath> Header C chuyển tên: bỏ .h, thêm c prefix

Lưu ý: Standard Library ≠ STL. STL (containers, iterators, algorithms, functors) là subset của Standard Library.