|
|
Line 1: |
Line 1: |
− | {{title|C++ language}}
| + | #REDIRECT [[Rust]] |
− | {{cpp/language/navbar}}
| + | |
− | | + | |
− | This is a reference of the core C++ language constructs.
| + | |
− | | + | |
− | {| cellpadding="5"
| + | |
− | |- valign="top"
| + | |
− | |
| + | |
− | | + | |
− | '''{{rl|basic concepts|Basic concepts}}'''
| + | |
− | <div class="mainpagediv">
| + | |
− | {{rlp|comment|Comments}}<br>
| + | |
− | {{rl|ascii|ASCII chart}}<br>
| + | |
− | {{rl|punctuators|Punctuation}}<br>
| + | |
− | {{rl|identifiers|Names and identifiers}}<br>
| + | |
− | {{rl|type|Types}} –
| + | |
− | {{rl|types|Fundamental types}}<br>
| + | |
− | {{rl|object|Object}} –
| + | |
− | {{rl|scope|Scope}} –
| + | |
− | {{rl|lifetime|Lifetime}}<br>
| + | |
− | {{rl|definition|Definitions and ODR}}<br>
| + | |
− | {{rl|lookup|Name lookup}}<br>
| + | |
− | {{nbsp}} {{rl|qualified lookup|qualified}} – {{rl|unqualified lookup|unqualified}} ({{rl|adl|ADL}})<br>
| + | |
− | {{rl|as if|As-if rule}}<br>
| + | |
− | {{rl|ub|Undefined behavior (UB)}}<br>
| + | |
− | {{rl|memory model|Memory model and data races}}<br>
| + | |
− | {{rl|charset|Character sets and encodings}}<br>
| + | |
− | {{rl|translation phases|Phases of translation}}<br>
| + | |
− | {{rl|main function|The {{tt|main}} function}}<br>
| + | |
− | {{rl|modules|Modules}} {{mark c++20}}<br>
| + | |
− | </div>
| + | |
− | | + | |
− | '''{{rlp|keyword|Keywords}}'''
| + | |
− | <div class="mainpagediv">
| + | |
− | <!-- -->
| + | |
− | </div>
| + | |
− | | + | |
− | '''{{rlp|preprocessor|Preprocessor}}'''
| + | |
− | <div class="mainpagediv">
| + | |
− | {{rlp|preprocessor/conditional|{{tt|#if}} - {{tt|#ifdef}} - {{tt|#ifndef}} - {{tt|#elif}}}}<br>
| + | |
− | {{rlp|preprocessor/conditional|{{tt|#elifdef}} - {{tt|#elifndef}}}} {{mark c++23}}<br>
| + | |
− | {{rlp|preprocessor/replace|{{tt|#define}} - {{tt|#}} - {{tt|##}}}}<br>
| + | |
− | {{rlpt|preprocessor/include|#include}} -
| + | |
− | {{rlpt|preprocessor/impl|#pragma}}<br>
| + | |
− | {{rlpt|preprocessor/line|#line}} -
| + | |
− | {{rlp|preprocessor/error|{{tt|#error}} - {{tt|#warning}}}} {{mark c++23}}<br>
| + | |
− | </div>
| + | |
− | | + | |
− | '''{{rl|expressions|Expressions}}'''
| + | |
− | <div class="mainpagediv">
| + | |
− | {{rl|value category|Value categories}}<br>
| + | |
− | {{rl|eval order|Evaluation order and sequencing}}<br>
| + | |
− | {{rl|constant expression|Constant expressions}}<br>
| + | |
− | {{rl|expressions#Operators|Operators}}<br>
| + | |
− | {{nbsp}} {{rl|operator assignment|assignment}} –
| + | |
− | {{rl|operator arithmetic|arithmetic}}<br>
| + | |
− | {{nbsp}} {{rl|operator incdec|increment and decrement}}<br>
| + | |
− | {{nbsp}} {{rl|operator logical|logical}} –
| + | |
− | {{rl|operator comparison|comparison}}<br>
| + | |
− | {{nbsp}} {{rl|operator member access|member access and indirection}}<br>
| + | |
− | {{nbsp}} {{rl|operator other|call, comma, ternary}}<br>
| + | |
− | {{nbsp}} {{rlt|sizeof}} – {{rlt|alignof}} {{mark c++11}}<br>
| + | |
− | {{nbsp}} {{rlt|new}} – {{rlt|delete}} – {{rlt|typeid}}<br>
| + | |
− | {{nbsp}} {{rl|operator_alternative|alternative representation}}<br>
| + | |
− | {{rl|operators|Operator overloading}}<br>
| + | |
− | {{rl|default comparisons|Default comparisons}} {{mark c++20}}<br>
| + | |
− | {{rl|operator precedence|Operator precedence}}<br>
| + | |
− | {{rl|expressions#Conversions|Conversions}}<br>
| + | |
− | {{nbsp}} {{rl|implicit conversion|implicit}} –
| + | |
− | {{rl|explicit cast|explicit}} –
| + | |
− | {{rl|cast operator|user-defined}}<br>
| + | |
− | {{nbsp}} {{rl|usual arithmetic conversions|Usual arithmetic conversions}}<br>
| + | |
− | {{nbsp}} {{rlt|static_cast}} – {{rlt|dynamic_cast}}<br>
| + | |
− | {{nbsp}} {{rlt|const_cast}} – {{rlt|reinterpret_cast}}<br>
| + | |
− | {{rl|expressions#Literals|Literals}} ({{rl|escape|Escape sequences}})<br>
| + | |
− | {{nbsp}} {{rl|bool literal|boolean}} –
| + | |
− | {{rl|integer literal|integer}} –
| + | |
− | {{rl|floating literal|floating}}<br>
| + | |
− | {{nbsp}} {{rl|character literal|character}} –
| + | |
− | {{rl|string literal|string}}<br>
| + | |
− | {{nbsp}} {{rlt|nullptr}} {{mark c++11}}<br>
| + | |
− | {{nbsp}} {{rl|user literal|user-defined (UDL)}} {{mark c++11}}<br>
| + | |
− | </div>
| + | |
− | | + | |
− | |
| + | |
− | | + | |
− | '''{{rl|declarations|Declarations}}'''
| + | |
− | <div class="mainpagediv">
| + | |
− | {{rl|namespace|Namespace declaration}}<br>
| + | |
− | {{rl|namespace alias|Namespace alias}}<br>
| + | |
− | {{rl|reference|References}} –
| + | |
− | {{rl|pointer|Pointers}} –
| + | |
− | {{rl|array|Arrays}}<br>
| + | |
− | {{rl|structured binding|Structured bindings}} {{mark c++17}}<br>
| + | |
− | {{rl|enum|Enumerations and enumerators}}<br>
| + | |
− | {{rl|storage duration|Storage duration and linkage}}<br>
| + | |
− | {{rl|tu local|Translation-unit-local}} {{mark c++20}}<br>
| + | |
− | {{rl|language linkage|Language linkage}}<br>
| + | |
− | {{rl|inline|{{tt|inline}} specifier}}<br>
| + | |
− | {{rl|asm|Inline assembly}}<br>
| + | |
− | {{rl|cv|{{tt|const}}/{{tt|volatile}}}}<br>
| + | |
− | {{rlt|constexpr}} {{mark c++11}}<br>
| + | |
− | {{rlt|consteval}} {{mark c++20}}<br>
| + | |
− | {{rlt|constinit}} {{mark c++20}}<br>
| + | |
− | {{rlt|decltype}} {{mark c++11}} – {{rlt|auto}} {{mark c++11}}<br>
| + | |
− | {{rlt|typedef}} – {{rl|type alias|Type alias}} {{mark c++11}}<br>
| + | |
− | {{rl|elaborated type specifier|Elaborated type specifiers}}<br>
| + | |
− | {{rl|attributes|Attributes}} {{mark c++11}}<br>
| + | |
− | {{rlt|alignas}} {{mark c++11}}<br>
| + | |
− | {{rlt|static_assert}} {{mark c++11}}<br>
| + | |
− | </div>
| + | |
− | | + | |
− | '''{{rl|initialization|Initialization}}'''
| + | |
− | <div class="mainpagediv">
| + | |
− | {{rl|default initialization|Default initialization}}<br>
| + | |
− | {{rl|value initialization|Value initialization}}<br>
| + | |
− | {{rl|copy initialization|Copy initialization}}<br>
| + | |
− | {{rl|direct initialization|Direct initialization}}<br>
| + | |
− | {{rl|aggregate initialization|Aggregate initialization}}<br>
| + | |
− | {{rl|list initialization|List initialization}} {{mark c++11}}<br>
| + | |
− | {{rl|reference initialization|Reference initialization}}<br>
| + | |
− | {{rl|initialization#Non-local variables|Static non-local initialization}}<br>
| + | |
− | {{nbsp}}{{rl|zero initialization|zero}} – {{rl|constant initialization|constant}}<br>
| + | |
− | {{rl|initialization#Non-local variables|Dynamic non-local initialization}}<br>
| + | |
− | {{nbsp}}{{rl|initialization#Non-local variables|ordered}} – {{rl|initialization#Non-local variables|unordered}}<br>
| + | |
− | {{rl|copy elision|Copy elision (RVO)}}
| + | |
− | </div>
| + | |
− | | + | |
− | '''{{rl|functions|Functions}}'''
| + | |
− | <div class="mainpagediv">
| + | |
− | {{rl|function|Function declaration}}<br>
| + | |
− | {{rl|default arguments|Default arguments}}<br>
| + | |
− | {{rl|variadic arguments|Variadic arguments}}<br>
| + | |
− | {{rl|lambda|Lambda expression}} {{mark c++11}}<br>
| + | |
− | {{rl|adl|Argument-dependent lookup}}<br>
| + | |
− | {{rl|overload resolution|Overload resolution}}<br>
| + | |
− | {{rl|operators|Operator overloading}}<br>
| + | |
− | {{rl|overloaded address|Address of an overload set}}<br>
| + | |
− | {{rl|coroutines|Coroutines}} {{mark c++20}}<br>
| + | |
− | </div>
| + | |
− | | + | |
− | '''{{rl|statements|Statements}}'''
| + | |
− | <div class="mainpagediv">
| + | |
− | {{rlt|if}} –
| + | |
− | {{rlt|switch}}<br>
| + | |
− | {{rlt|for}} –
| + | |
− | {{rl|range-for|range-{{tt|for}}}} {{mark c++11}}<br>
| + | |
− | {{rlt|while}} – {{rl|do|{{tt|do}}-{{tt|while}}}}<br>
| + | |
− | {{rlt|continue}} –
| + | |
− | {{rlt|break}} –
| + | |
− | {{rlt|goto}} –
| + | |
− | {{rlt|return}}<br>
| + | |
− | {{rl|transactional memory|{{tt|synchronized}} and {{tt|atomic}}}} {{mark since tm ts}}<br>
| + | |
− | </div>
| + | |
− | | + | |
− | |
| + | |
− | | + | |
− | '''{{rl|classes|Classes}}'''
| + | |
− | <div class="mainpagediv">
| + | |
− | {{rl|class|Class types}} –
| + | |
− | {{rl|union|Union types}}<br>
| + | |
− | {{rl|injected-class-name}}<br>
| + | |
− | {{rl|data members|Data members}} –
| + | |
− | {{rl|bit field|Bit-fields}}<br>
| + | |
− | {{rl|member functions|Member functions}} –
| + | |
− | {{rl|this|The {{tt|this}} pointer}}<br>
| + | |
− | {{rl|static|Static members}} –
| + | |
− | {{rl|nested types|Nested classes}}<br>
| + | |
− | {{rl|derived class|Derived class}} –
| + | |
− | {{rl|using declaration|{{tt|using}}-declaration}}<br>
| + | |
− | {{rl|ebo|Empty base optimization (EBO)}}<br>
| + | |
− | {{rl|virtual|Virtual function}} –
| + | |
− | {{rl|abstract class|Abstract class (ABC)}}<br>
| + | |
− | {{rlt|override}} {{mark c++11}} – {{rlt|final}} {{mark c++11}}<br>
| + | |
− | {{rl|access|Member access}} –
| + | |
− | {{rlt|friend}}<br>
| + | |
− | {{rl|constructor|Constructors and member initializer lists}}<br>
| + | |
− | {{rl|default constructor|Default constructor}} –
| + | |
− | {{rl|destructor|Destructor}}<br>
| + | |
− | {{rl|copy constructor|Copy constructor}} –
| + | |
− | {{rl|copy assignment|Copy assignment}}<br>
| + | |
− | {{rl|move constructor|Move constructor}} {{mark c++11}}<br>
| + | |
− | {{rl|move assignment|Move assignment}} {{mark c++11}}<br>
| + | |
− | {{rl|converting constructor|Converting constructor}}<br>
| + | |
− | {{rl|explicit|{{tt|explicit}} specifier}}<br>
| + | |
− | </div>
| + | |
− | | + | |
− | '''{{rl|templates|Templates}}'''
| + | |
− | <div class="mainpagediv">
| + | |
− | {{rl|template parameters|Template parameters and arguments}}<br>
| + | |
− | {{rl|class template|Class template}} –
| + | |
− | {{rl|function template|Function template}}<br>
| + | |
− | {{rl|variable template|Variable template}} {{mark c++14}}<br>
| + | |
− | {{rl|member template|Class member template}}<br>
| + | |
− | {{rl|template argument deduction|Template argument deduction}}<br>
| + | |
− | {{rl|class template argument deduction|Class template argument deduction (CTAD)}} {{mark c++17}}<br>
| + | |
− | {{rl|template specialization|Explicit specialization}} – {{rl|partial specialization|Partial specialization}}<br>
| + | |
− | {{rl|parameter pack|Parameter packs}} {{mark c++11}} –
| + | |
− | {{rlt|sizeof...}} {{mark c++11}}<br>
| + | |
− | {{rl|fold|Fold-expressions}} {{mark c++17}}<br>
| + | |
− | {{rl|dependent name|Dependent names}} –
| + | |
− | {{rl|sfinae|SFINAE}}<br>
| + | |
− | {{rl|constraints|Constraints and concepts}} {{mark c++20}}<br>
| + | |
− | {{rl|requires|Requires expression}} {{mark c++20}}<br>
| + | |
− | </div>
| + | |
− | | + | |
− | '''{{rl|exceptions|Exceptions}}'''
| + | |
− | <div class="mainpagediv">
| + | |
− | {{rl|throw|{{tt|throw}}-expression}}<br>
| + | |
− | {{rl|try catch|{{tt|try}}-{{tt|catch}} block}}<br>
| + | |
− | {{rl|function-try-block|Function-{{tt|try}}-block}}<br>
| + | |
− | {{rl|noexcept spec|{{tt|noexcept}} specifier}} {{mark c++11}}<br>
| + | |
− | {{rl|noexcept|{{tt|noexcept}} operator}} {{mark c++11}}<br>
| + | |
− | {{rl|except spec|Dynamic exception specification}} {{mark tooltip|until C++17|deprecated in C++11}}<br>
| + | |
− | </div>
| + | |
− | | + | |
− | '''Miscellaneous'''
| + | |
− | <div class="mainpagediv">
| + | |
− | {{rl|history|History of C++}}<br>
| + | |
− | {{rl|extending std|Extending the namespace std}}<br>
| + | |
− | {{rl|acronyms|Acronyms}}:
| + | |
− | [[cpp/ranges/cpo|CPO]], | + | |
− | [[cpp/language/ndr|IFNDR]],
| + | |
− | [[cpp/language/ndr|NDR]],
| + | |
− | [[cpp/string/byte|NTBS]],<br>
| + | |
− | [[cpp/language/template_parameters|NTTP]],
| + | |
− | [[cpp/ranges#Range adaptor objects|RAO]],
| + | |
− | [[cpp/memory/allocator_traits/select_on_container_copy_construction|SOCCC]],
| + | |
− | [[cpp/language/template metaprogramming|TMP]],
| + | |
− | [[cpp/language/translation phases#Phase 8|TU]]
| + | |
− | </div>
| + | |
− | | + | |
− | '''Idioms'''
| + | |
− | <div class="mainpagediv">
| + | |
− | {{rl|crtp|Curiously Recurring Template Pattern (CRTP)}}<br>
| + | |
− | {{rl|pimpl|Pointer to implementation (PIMPL)}}<br>
| + | |
− | {{rl|raii|Resource acquisition is initialization (RAII)}}<br>
| + | |
− | {{rl|rule of three|Rule of three/five/zero}}<br>
| + | |
− | {{rl|Zero-overhead principle|Zero-overhead principle}}<br>
| + | |
− | </div>
| + | |
− | |}
| + | |
− | | + | |
− | ===See also===
| + | |
− | {{dsc begin}}
| + | |
− | {{dsc see c|c/language|C language constructs|nomono=true}}
| + | |
− | {{dsc end}}
| + | |
− | | + | |
− | {{langlinks|ar|de|es|fr|it|ja|ko|pl|pt|ru|tr|zh}}
| + | |