aboutsummaryrefslogtreecommitdiffstats
path: root/source/lang/keywords.rst
blob: e4ebe9911a5a095a6cc422bd8c4988bc7e0fe6be (plain)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
.. _lang-keywords:

Keywords
========

This page lists all of the C++ keywords, and either links to a
reference page explaining their use, or provides a brief description.

List of Keywords
----------------

The C++ keywords are:

``and``, ``and_eq``, ``asm``, ``auto``, ``bitand``, ``bitor``,
``bool``, ``break``, ``case``, ``catch``, ``char``, ``class``,
``compl``, ``const``, ``const_cast``, ``continue``, ``default``,
``delete``, ``do``, ``double``, ``dynamic_cast``, ``else``, ``enum``,
``explicit``, ``export``, ``extern``, ``false``, ``float``, ``for``,
``friend``, ``goto``, ``if``, ``inline``, ``int``, ``long``,
``mutable``, ``namespace``, ``new``, ``not``, ``not_eq``,
``operator``, ``or``, ``or_eq``, ``private``, ``protected``,
``public``, ``register``, ``reinterpret_cast``, ``return``, ``short``,
``signed``, ``sizeof``, ``static``, ``static_cast``, ``struct``,
``switch``, ``template``, ``this``, ``throw``, ``true``, ``try``,
``typedef``, ``typeid``, ``typename``, ``union``, ``unsigned``,
``using``, ``virtual``, ``void``, ``volatile``, ``wchar_t``,
``while``, ``xor``, ``xor_eq``

Boolean Operator Synonyms
-------------------------

- ``and`` is a synonym for :ref:`&& <lang-boolean-and>`.
- ``not`` is a synonym for :ref:`\! <lang-boolean-not>`.
- ``not_eq`` is a synonym for :ref:`\!= <lang-comparison>`.
- ``or`` is a synonym for :ref:`|| <lang-boolean-or>`.

Bitwise Operator Synonyms
-------------------------

- ``and_eq`` is a synonym for :ref:`&= <lang-compoundbitwise-and>`.
- ``bitand`` is a synonym for (bitwise) :ref:`& <lang-bitwisemath-and>`.
- ``bitor`` is a synonym for :ref:`\| <lang-bitwisemath-or>`.
- ``compl`` is a synonym for :ref:`~ <lang-bitwisemath-not>`.
- ``or_eq`` is a synonym for :ref:`|= <lang-compoundbitwise-or>`.
- ``xor`` is a synonym for :ref:`^ <lang-bitwisemath-xor>`.
- ``xor_eq`` is a synonym for :ref:`^= <lang-compoundbitwise-xor>`.

Constants
---------

- ``true`` and ``false`` are the :ref:`boolean constants
  <lang-booleanvariables>`.

Control Flow
------------

- ``break`` can exit out of a :ref:`switch statement
  <lang-switchcase>` or a :ref:`for <lang-for>`, :ref:`do
  <lang-dowhile>`, or :ref:`while <lang-while>` loop.

- ``case`` defines alternatives in a :ref:`switch statement <lang-switchcase>`.

- ``continue`` will move control flow to the next iteration of the
  enclosing :ref:`for <lang-for>`, :ref:`do <lang-dowhile>`, or
  :ref:`while <lang-while>` loop.

- ``default`` defines the default alternative in a :ref:`switch
  statement <lang-switchcase>`.

- ``do`` introduces a :ref:`do <lang-dowhile>` loop.

- ``else`` is used in :ref:`if statements <lang-if>`.

- ``for`` introduces a :ref:`for <lang-for>` loop.

- ``goto`` :ref:`jumps <lang-goto>` to a label.

- ``if`` introduces an :ref:`if statement <lang-if>`.

- ``return`` :ref:`transfers flow to a function's caller <lang-return>`.

- ``switch`` introduces a :ref:`switch statement <lang-switchcase>`.

- ``while`` introduces a :ref:`while <lang-while>` loop.

Types
-----

The following keywords are used for built-in types.

- :ref:`bool <lang-booleanvariables>`
- :ref:`lang-char`
- :ref:`lang-double`
- :ref:`lang-float`
- :ref:`lang-int`
- :ref:`lang-long`
- :ref:`short <lang-numeric-types-integral>`
- :ref:`void <lang-void>` (not really a type, but used in the absence
  of one)

The following keywords are used to introduce new types.

- :ref:`enum <lang-enum>`

Qualifiers
----------

- :ref:`static <lang-static>` can be used to declare persistent local
  variables; it has other uses not documented here.

- ``unsigned`` is used to specify an unsigned integral type.
  Examples: :ref:`lang-unsignedint`, :ref:`lang-unsignedchar`,
  :ref:`lang-unsignedlong`.

- :ref:`volatile <lang-volatile>` is useful when declaring variables
  that may be modified by external interrupts.

- :ref:`const <lang-const>` is used to define constants.

Other
-----

These keywords are not described in the Maple documentation.  For more
information, consult a C++ reference.

- ``asm`` is used to insert literal assembly language.

- ``auto`` is used to declare that a variable has automatic storage.

- ``catch`` is used in exception handling.  Note that the default
  flags we pass to :ref:`GCC <arm-gcc>` include ``-fno-exceptions``.

- ``class`` is used to define classes.

- ``const_cast`` is used in typecasting.

- ``delete`` is used to free ``new``\ -allocated storage.  Note that
  dynamic memory allocation is not available by default on the Maple,
  so you'll have to bring your own ``new`` and ``delete`` if you want
  this.

- ``dynamic_cast`` is used in typecasting.

- ``explicit`` is used to declare constructors that can be called only
  explicitly.

- ``export`` declares a template definition accessible to other
  compilation units.

- ``extern`` can mark a declaration as a declaration and not a
  definition, and also grant external linkage to a ``const`` or
  ``typedef``.

- ``friend`` is used to declare that certain functions have access to
  a class's private variables.

- ``inline`` is a compiler hint to inline a function.

- ``mutable`` specifies that a member can be updated, even when a
  member of a ``const`` object.

- ``namespace`` declares a new namespace.

- ``new`` dynamically allocates space for a value.  Note that dynamic
  memory allocation is not available by default on the Maple, so
  you'll have to bring your own ``new`` and ``delete`` if you want
  this.

- ``operator`` is used to define type-specific operator overrides.

- ``private`` declares a private class member.

- ``protected`` declares a protected class member.

- ``public`` declares a public class member.

- ``register`` is a compiler hint to store a variable in a register.

- ``reinterpret_cast`` is used in typecasting.

- ``signed`` is the opposite of ``unsigned``.

- ``static_cast`` is used in typecasting.

- ``struct`` declares a new struct.

- ``template`` introduces a template class, function, etc.

- ``this`` is a pointer to the receiver object.

- ``throw`` is used in exception handling.  Note that the default
  flags we pass to :ref:`GCC <arm-gcc>` include ``-fno-exceptions``.

- ``try`` is used in exception handling.  Note that the default
  flags we pass to :ref:`GCC <arm-gcc>` include ``-fno-exceptions``.

- ``typedef`` defines a type synonym.

- ``union`` defines an untagged union.

- ``using`` is a directive related to namespaces.

- ``virtual`` declares a method which may be overridden.

- ``wchar_t`` is the wide character type.