1 2 3 4 5 6 7 8 | #include <iostream> using namespace std; // main() is where program execution begins. int main() { cout << "Hello World"; // prints Hello World return 0; } |
1 2 3 4 5 6 7 8 | // Single line comments number++; // comment in line with code /* Multi line comments spread over multiple lines */ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | // Primitive Types bool // Boolean char // Character int // Integer float // Floating point double // Double floating point void // Valueless wchar_t // Wide character // Type Modifiers signed // unsigned // short // long // // All available types char // 1byte. -127 to 127 or 0 to 255 unsigned char // 1byte. 0 to 255 signed char // 1byte. -127 to 127 int // 4bytes. -2147483648 to 2147483647 unsigned int // 4bytes. 0 to 4294967295 signed int // 4bytes. -2147483648 to 2147483647 short int // 2bytes. -32768 to 32767 unsigned short int // 2bytes. 0 to 65,535 signed short int. // 2bytes. -32768 to 32767 long int // 8bytes. -9223372036854775808 to 9223372036854775807 signed long int // 8bytes. same as long int unsigned long int // 8bytes. 0 to 18446744073709551615 long long int // 8bytes. -(2^63) to (2^63)-1 unsigned long long int // 8bytes. 0 to 18,446,744,073,709,551,615 float // 4bytes double // 8bytes long double // 12bytes wchar_t 2 or 4 bytes // 1 wide character |
1 2 3 | // Typedef typedef unsigned char BYTE; BYTE b1, b2; |
1 2 3 4 5 | // Modifiers const // Objects of type const cannot be changed by your program during execution. volatile // Variable's value may be changed in ways not explicitly specified by the program. restrict // A pointer qualified by restrict is initially the only means by which the object it points to can be accessed |
1 | // Literals |
1 | // Constants |
1 2 3 4 5 6 7 | // Storage Classes auto // register // static // extern // mutable // |
1 2 3 4 5 6 7 8 9 | // Arithmetic Operators + // Adds two operands A + B will give 30 - // Subtracts second operand from the first A - B will give -10 * // Multiplies both operands A * B will give 200 / // Divides numerator by de-numerator B / A will give 2 % // Modulus Operator and remainder of after an integer division B % A will give 0 ++ // Increment operator, increases integer value by one A++ will give 11 -- // Decrement operator, decreases integer value by one A-- will give 9 |
1 2 3 4 5 6 7 8 | // Relational Operatorrs == // Checks if the values of two operands are equal or not, if yes then condition becomes true. != // Checks if the values of two operands are equal or not, if values are not equal then condition becomes true. > // Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. < // Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true. >= // Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. <= // Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. |
1 2 3 4 5 6 7 8 | // Bitwise Operators & // Binary AND Operator copies a bit to the result if it exists in both operands. | // Binary OR Operator copies a bit if it exists in either operand. ^ // Binary XOR Operator copies the bit if it is set in one operand but not both. ~ // Binary Ones Complement Operator is unary and has the effect of 'flipping' bits. << // Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand. >> // Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. |
1 2 3 4 5 6 | // Logical Operators && // Called Logical AND operator. If both the operands are non-zero, then condition becomes true. || // Called Logical OR Operator. If any of the two operands is non-zero, then condition becomes true. ! // Called Logical NOT Operator. Use to reverses the logical state of its operand. // If a condition is true, then Logical NOT operator will make false. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // Assignment Operators = // Simple assignment operator, Assigns values from right side operands to left side operand. += // Add AND assignment operator, It adds right operand to the left operand and assign the result to left operand. -= // Subtract AND assignment operator, It subtracts right operand from the left operand and assign the result to left operand. *= // Multiply AND assignment operator, It multiplies right operand with the left operand and assign the result to left operand. /= // Divide AND assignment operator, It divides left operand with the right operand and assign the result to left operand. %= // Modulus AND assignment operator, It takes modulus using two operands and assign the result to left operand. <<= // Left shift AND assignment operator. >>= // Right shift AND assignment operator. &= // Bitwise AND assignment operator. ^= // Bitwise exclusive OR and assignment operator. |= // Bitwise inclusive OR and assignment operator. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | // Decision making if(boolean_expression) { /* statement(s) will execute if the boolean expression is true */ } if(boolean_expression) { /* statement(s) will execute if the boolean expression is true */ } else { /* statement(s) will execute if the boolean expression is false */ } if( boolean_expression 1) { /* Executes when the boolean expression 1 is true */ if(boolean_expression 2) { /* Executes when the boolean expression 2 is true */ } } switch(expression) { case constant-expression : statement(s); break; /* optional */ case constant-expression : statement(s); break; /* optional */ /* you can have any number of case statements */ default : /* Optional */ statement(s); } switch(ch1) { case 'A': printf("This A is part of outer switch" ); switch(ch2) { case 'A': printf("This A is part of inner switch" ); break; case 'B': /* case code */ } break; case 'B': /* case code */ } Exp1 ? Exp2 : Exp3; // If Exp1 is True, Exp2 else Exp3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | // Loops while(condition) { statement(s); } while(condition) { while(condition) { statement(s); } statement(s); } for ( init; condition; increment ) { statement(s); } for ( init; condition; increment ) { for ( init; condition; increment ) { statement(s); } statement(s); } do { statement(s); } while( condition ); do { statement(s); do { statement(s); }while( condition ); } while( condition ); // Infinite Loop for( ; ; ) { printf("This loop will run forever.\n"); } while( some)boolean_expression() ) { do_something() if(some_other_boolean() ) { /* terminate the loop using break statement */ break; } } while( some)boolean_expression() ) { do_something() if(some_other_boolean() ) { /* skip the iteration */ continue; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | // Functions // Definition return_type function_name( parameter list ) { body of the function } // Declaration return_type function_name( parameter list ); // Call by value void add(int x, int y) { return x + y } result = swap(a, b); // Call by reference void swap(int *x, int *y) { // Swap two numbers return; // No return value } swap(&a, &b); // Inline Functions / Code copied by compiler into each instance inline int Max(int x, int y) { return (x > y)? x : y; } cout << "Max (20,10): " << Max(20,10) << endl; cout << "Max (0,200): " << Max(0,200) << endl; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | // Arrays // type arrayName [ arraySize ]; int intArray1[10]; int intArray2[5] = {1, 2, 3, 4, 5}; double balance[] = {1000.0, 2.0, 3.4, 7.0, 50.0}; intArray[0] == 1 intArray[4] == 5 // Multi Dimension // type name[size1][size2]...[sizeN]; int a[3][4] = { {0, 1, 2, 3} , /* initializers for row indexed by 0 */ {4, 5, 6, 7} , /* initializers for row indexed by 1 */ {8, 9, 10, 11} /* initializers for row indexed by 2 */ }; // Passing arrays to functions void myFunction(int *param) // Formal parameters as a pointer void myFunction(int param[10]) // Formal parameters as a sized area void myFunction(int param[]) // Formal parameters as an unsized array // Returning arrays from function ( as pointer only ) int * myFunction() // POinters to arrays double *p; double balance[10]; p = balance; *p == balance[0] == *balance *(p+1) == balance[1] == *(balance+1) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | // Pointers int *ip; /* pointer to an integer */ double *dp; /* pointer to a double */ float *fp; /* pointer to a float */ char *ch /* pointer to a character */ int var = 20; /* actual variable declaration */ int *ip; /* pointer variable declaration */ ip = &var; /* store address of var in pointer variable*/ int **pptr; /* pointer to a pointer &var // Address of var ip // Address or var stored in a pointer p *ip // Value of var pointed to by p pptr = &ptr; **pptr // The value of var pointer to by pptr which points to p // Null Pointer, value 0 int *ptr = NULL; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // Strings ( 1D Arrays ) char greeting[6] = {'H', 'e', 'l', 'l', 'o', '\0'}; // Null terminated string char greeting[] = "Hello"; // Automatically null terminated printf("Greeting message: %s\n", greeting ); // Null terminated string methods strcpy(s1, s2); // Copies string s2 into string s1. strcat(s1, s2); // Concatenates string s2 onto the end of string s1. strlen(s1); // Returns the length of string s1. strcmp(s1, s2); // Returns 0 if s1 and s2 are the same; less than 0 if s1<s2; greater than 0 if s1>s2. strchr(s1, ch); // Returns a pointer to the first occurrence of character ch in string s1. strstr(s1, s2); // Returns a pointer to the first occurrence of string s2 in string s1. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | // Basic Input/Output #include <iostream> using namespace std; int main() { char str[] = "Hello C++"; cout << "Value of str is : " << str << endl; char name[50]; cout << "Please enter your name: "; cin >> name; cout << "Your name is: " << name << endl; char str[] = "Unable to read...."; cerr << "Error message : " << str << endl; clog << "Error message : " << str << endl; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | // Classes & Objects class Box { public: double length; // Length of a box double breadth; // Breadth of a box double height; // Height of a box double getVolume(void) { return length * breadth * height; } }; // Alternative with scope resolution operator :: class Box { public: double length; // Length of a box double breadth; // Breadth of a box double height; // Height of a box // Member functions declaration double getVolume(void); }; // Member functions definitions double Box::getVolume(void) { return length * breadth * height; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 | // Class Access Modifiers class Base { public: // Visible Anywhere // public members go here protected: // Visible inside the class and to child classes // protected members go here private: // Visible inside the class only // private members go here }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | // Constructors & Destructors class Line { public: void setLength( double len ); double getLength( void ); Line(); // This is the constructor Line(double length); // This is a parameterized constructor private: double length; }; Line::Line(void) { cout << "Object is being created, length 0" << endl; this->length - 0 } Line::Line(double leng) { cout << "Object is being created, leng = " << length << endl; length = length } // Alternative Line::Line( double len): length(len) { cout << "Object is being created, length = " << len << endl; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | // Copy Constructor class Line { public: Line( const Line &obj); // copy constructor private: int *ptr; }; Line::Line(const Line &obj) { cout << "Copy constructor allocating ptr." << endl; ptr = new int; *ptr = *obj.ptr; // copy the value } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | // Friend Function class Box { double width; public: double length; friend void printWidth( Box box ); }; // Note: printWidth() is not a member function of any class. void printWidth( Box box ) { /* Because printWidth() is a friend of Box, it can directly access any member of this class */ cout << "Width of box : " << box.width <<endl; } |
1 2 3 4 5 6 7 8 9 10 11 | // this-> pointer class Box { public: double Volume() { return length * breadth * height; } int compare(Box box) { return this->Volume() > box.Volume(); } }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // Static Members class Box { public: static int objectCount; Box() { objectCount++ } static int getCount() { return objectCount; } }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | // Inheritance class Base: public: Base() { // do Something } }; class Derived1: Base public: Derived1(): Base() { // do Something } } class Base2: public: Base2() { // do Something } }; class Derived1: Base, Base2 public: Derived1(): Base(), Base2() { // do Something } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | // Overloading class printData { public: void print(int i) { cout << "Printing int: " << i << endl; } void print(double f) { cout << "Printing float: " << f << endl; } void print(char* c) { cout << "Printing character: " << c << endl; } }; // Overloadable Operators + - * / % ^ & | ~ ! , = < > <= >= ++ -- << >> == != && || += -= /= %= ^= &= |= *= <<= >>= [] () -> ->* new new [] delete delete [] // Non Overloadable Operators :: .* . ?: |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | // Polymorphism class Shape { protected: int width, height; public: Shape( int a = 0, int b = 0){ } int area() { } }; class Rectangle: public Shape { public: Rectangle( int a = 0, int b = 0):Shape(a, b) { } int area () { } }; class Triangle: public Shape { public: Triangle( int a = 0, int b = 0):Shape(a, b) { } int area () { } }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | // Abstraction class Adder { public: // constructor Adder(int i = 0) { total = i; } // interface to outside world void addNum(int number) { total += number; } private: // hidden data from outside world int total; }; int main() { Adder a; a.addNum(10); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | // Encapsulation #include <iostream> using namespace std; class Adder { public: // constructor Adder(int i = 0) { total = i; } // interface to outside world void addNum(int number) { total += number; } // interface to outside world int getTotal() { return total; }; private: // hidden data from outside world int total; }; int main() { Adder a; a.addNum(10); a.addNum(20); a.addNum(30); cout << "Total " << a.getTotal() <<endl; return 0; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | // Interfaces class Interface { public: Interface(){} virtual ~Interface(){} virtual void method1() = 0; // "= 0" part makes this method pure virtual, and // also makes this class abstract. virtual void method2() = 0; }; class Concrete : public Interface { private: int myMember; public: Concrete(){} ~Concrete(){} void method1(); void method2(); }; // Provide implementation for the first method void Concrete::method1() { // Your implementation } // Provide implementation for the second method void Concrete::method2() { // Your implementation } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | // Files and Streams // File Data Types #include <fstream> ofstream // This data type represents the output file stream and is used to create files and to write information to files. ifstream // This data type represents the input file stream and is used to read information from files. fstream // This data type represents the file stream generally, and has the capabilities of both ofstream and ifstream which means it can create files, write information to files, and read information from files. // Open A File void open(const char *filename, ios::openmode mode); // Open Models ios::app // Append mode. All output to that file to be appended to the end. ios::ate // Open a file for output and move the read/write control to the end of the file. ios::in // Open a file for reading. ios::out // Open a file for writing. ios::trunc // If the file already exists, its contents will be truncated before opening the file. // Close A File void close(); // Write To A File ofstream outfile; outfile.open("afile.dat"); outfile << data << endl; // Read to a File char data[100]; ifstream infile; infile.open("afile.dat"); infile >> data; // File Pointers // position to the nth byte of fileObject (assumes ios::beg) fileObject.seekg( n ); // position n bytes forward in fileObject fileObject.seekg( n, ios::cur ); // position n bytes back from end of fileObject fileObject.seekg( n, ios::end ); // position at end of fileObject fileObject.seekg( 0, ios::end ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | // Exception Handling try { // protected code } catch( ExceptionName e1 ) { // catch block } catch( ExceptionName e2 ) { // catch block } catch( ExceptionName eN ) { // catch block } try { throw "Division by zero condition!"; } catch (const char* msg) { do_Something() } throw "Division by zero condition!"; // Customer Exceptions struct MyException : public exception { const char * what () const throw () { return "C++ Exception"; } }; try { throw MyException(); } catch(MyException& e) { std::cout << "MyException caught" << std::endl; std::cout << e.what() << std::endl; } catch(std::exception& e) { //Other errors } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | // Dynamic Memory // Types double* pvalue = NULL; // Pointer initialized with null pvalue = new double; // Request memory for the variable if( !(pvalue = new double )) { cout << "Error: out of memory." <<endl; exit(1); } delete pvalue; // Release memory pointed to by value // Arrays char* pvalue1 = NULL; // Pointer initialized with null char* pvalue2 = NULL; // Pointer initialized with null pvalue1 = new char[20]; // Request memory for the variable pvalue2 = new char[20][20]; // Request memory for the variable delete [] pvalue1; delete [] pvalue2; // Objects class Box { }; Box* myBoxArray = new Box[4]; delete [] myBoxArray; // Delete array |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | // Preprocessor #define macro-name replacement-text // Macros #define MIN(a,b) (((a)<(b)) ? a : b) // Conditional Compilation #ifndef NULL #define NULL 0 #endif // # Operator // The # operator causes a replacement-text token to be converted to a string surrounded by quotes. #define MKSTR( x ) #x // ## Operator // The ## operator is used to concatenate two tokens. #define CONCAT( x, y ) x ## y // Pre-defined macros __LINE__ // This contains the current line number of the program when it is being compiled. __FILE__ // This contains the current file name of the program when it is being compiled. __DATE__ // This contains a string of the form month/day/year that is the date of the translation of the source file into object code. __TIME__ // This contains a string of the form hour:minute:second that is the time at which the program was compiled. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | // Namespaces namespace namespace_name { // code declarations } namespace_name::variable; namespace_name::function; // Different names spaces with the same named function. Use the 'using' // directive to switch between name spaces #include <iostream> using namespace std; // first name space namespace first_space { void func() { cout << "Inside first_space" << endl; } } // second name space namespace second_space { void func() { cout << "Inside second_space" << endl; } } using namespace first_space; int main () { // This calls function from first name space. func(); return 0; } // Here court doesn't need std::, but other items in the std namespace // will still need to be explicit as follows #include <iostream> using std::cout; int main () { cout << "std::endl is used with std!" << std::endl; return 0; } // Discontiguous Namespavces // file1.cpp namespace namespace_name { // code declarations } // files2.cpp namespace namespace_name { // code declarations } // All vars and functions in both files are in the same namespace // Nested namespace namespace namespace_name1 { // code declarations namespace namespace_name2 { // code declarations } } // to access members of namespace_name2 using namespace namespace_name1::namespace_name2; // to access members of namespace:name1 using namespace namespace_name1; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | // Templates // Function Templates template <class type> ret-type func-name(parameter list) { // body of function } template <typename T> inline T const& Max (T const& a, T const& b) { return a < b ? b:a; } int i = 39; int j = 20; int iresult = Max(i, j); double f1 = 13.5; double f2 = 20.7; double dresult = Max(f1, f2); string s1 = "Hello"; string s2 = "World"; sresult = Max(s1, s2); // Class Template template <class type> class class-name { . // Class Internals . } template <class T> class Stack { private: vector<T> elems; // elements public: void push(T const&); // push element void pop(); // pop element T top() const; // return top element bool empty() const { // return true if empty. return elems.empty(); } }; template <class T> void Stack<T>::push (T const& elem) { } template <class T> void Stack<T>::pop () { } template <class T> T Stack<T>::top () const { } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | // STL Library <pair> <vector> <list> <stack> <queue> <priority_queue> <set> <map> <unordered_set> <unordered_map> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | // C++ Keywords asm else new this auto enum operator throw bool explicit private true break export protected try case extern public typedef catch false asm else auto enum operator throw bool explicit private true break export protected try case. extern public typedef catch false register typeid char float reinterpret_cast typename class for return union const friend short unsigned const_cast goto signed using continue if sizeof virtual default inline static void delete int static_cast volatile do long struct wchar_t double mutable switch this dynamic_cast namespace template new char float reinterpret_cast class for return const friend short const_cast goto signed continue if sizeof default inline static delete int static_cast do long struct double mutable switch dynamic_cast namespace template |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | // C++ Standard Libraries <concepts> // Fundamental library concepts <coroutine> // Coroutine support library <any> // std::any class <bitset> // std::bitset class template <chrono> // C++ time utilities <compare> // Three-way comparison operator support <csetjmp> // Macro (and function) that saves (and jumps) to an execution context <signal> // Functions and macro constants for signal management <cstdarg> // Handling of variable length argument lists <cstddef> // Standard macros and typedefs <cstdlib> // General purpose utilities: program control, dynamic memory allocation, random numbers, sort and search <ctime> // C-style time/date utilities <expected> // std::expected class template <functional> // Function objects, Function invocations, Bind operations and Reference wrappers <initializer_list> // std::initializer_list class template <optional> // std::optional class template <source_location> // Supplies means to obtain source code location <tuple> // std::tuple class template <type_traits> // Compile-time type information <typeindex> // std::type_index <typeinfo> // Runtime type information utilities <utility> // Various utility components <variant> // std::variant class template <version> // Supplies implementation-dependent library information <memory> // High-level memory management utilities <memory_resource> // Polymorphic allocators and memory resources <new> // Low-level memory management utilities <scoped_allocator> // Nested allocator class <cfloat> // Limits of floating-point types <cinttypes> // Formatting macros, intmax_t and uintmax_t math and conversions <climits> // Limits of integral types <cstdint> // Fixed-width integer types and limits of other types <limits> // Uniform way to query properties of arithmetic types <stdfloat> // Optional extended floating-point types <cassert> // Conditionally compiled macro that compares its argument to zero <cerrno> // Macro containing the last error number <exception> // Exception handling utilities <stacktrace> // Stacktrace library <stdexcept> // Standard exception objects <system_error> // Defines std::error_code, a platform-dependent error code <cctype> // Functions to determine the category of narrow characters <charconv> // std::to_chars and std::from_chars <string> // Various narrow character string handling functions <cuchar> // C-style Unicode character conversion functions <cwchar> // Various wide and multibyte string handling functions <cwctype> // Functions to determine the catagory of wide characters <format> // Formatting library including std::format <string> // std::basic_string class template <string_view> // std::basic_string_view class template <array> // std::array container <deque> // std::deque container <flat_map> // std::flat_map and std::flat_multimap container adaptors <flat_set> // std::flat_set and std::flat_multiset container adaptors <forward_list> // std::forward_list container <list> // std::list container <map> // std::map and std::multimap associative containers <mdspan> // std::mdspan view <queue> // std::queue and std::priority_queue container adaptors <set> // std::set and std::multiset associative containers <span> // std::span view <stack> // std::stack container adaptor <unordered_map> // std::unordered_map and std::unordered_multimap unordered associative containers <unordered_set> // std::unordered_set and std::unordered_multiset unordered associative containers <vector> // std::vector container <iterator> // Range iterators <generator> // std::generator class template <ranges> // Range access, primitives, requirements, utilities and adaptors <algorithm> // Algorithms that operate on ranges <execution> // Predefined execution policies for parallel versions of the algorithms <bit> // Bit manipulation functions <cfenv> // Floating-point environment access functions <cmath> // Common mathematics functions <complex> // Complex number type <numbers> // Math constants <numeric> // Numeric operations on values in ranges <random> // Random number generators and distributions <ratio> // Compile-time rational arithmetic <valarray> // Class for representing and manipulating arrays of values <locale> // C localization utilities <codecvt> // Unicode conversion facilities <locale> // Localization utilities <cstdio> // C-style input-output functions <stream> // std::basic_fstream, std::basic_ifstream, std::basic_ofstream class templates and several typedefs <iomanip> // Helper functions to control the format of input and output <ios> // std::ios_base class, std::basic_ios class template and several typedefs <iosfwd> // Forward declarations of all classes in the input/output library <iostream> // Several standard stream objects <istream> // std::basic_istream class template and several typedefs <ostream> // std::basic_ostream, std::basic_iostream class templates and several typedefs <print> // Formatted output library including std::print <spanstream> // std::basic_spanstream, std::basic_ispanstream, std::basic_ospanstream class templates and typedefs <stream> // std::basic_stringstream, std::basic_istringstream, std::basic_ostringstream class templates and several typedefs <streambuf> // std::basic_streambuf class template <strstream> // std::strstream, std::istrstream, std::ostrstream <syncstream> // std::basic_osyncstream, std::basic_syncbuf, and typedefs <filesystem> // std::path class and supporting functions <regex> // Classes, algorithms and iterators to support regular expression processing <atomic> // Atomic operations library <barrier> // Barriers <condition_variable> // Thread waiting conditions <future> // Primitives for asynchronous computations <latch> // Latches <mutex> // Mutual exclusion primitives <semaphore> // Semaphores <shared_mutex> // Shared mutual exclusion primitives <stop_token> // Stop tokens for std::jthread <thread> // std::thread class and supporting functions |