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