Namespaces
Variants

Punctuation

From cppreference.net
C++ language
General topics
Flow control
Conditional execution statements
Iteration statements (loops)
Jump statements
Functions
Function declaration
Lambda function expression
inline specifier
Dynamic exception specifications ( until C++17* )
noexcept specifier (C++11)
Exceptions
Namespaces
Types
Specifiers
constexpr (C++11)
consteval (C++20)
constinit (C++20)
Storage duration specifiers
Initialization
Expressions
Alternative representations
Literals
Boolean - Integer - Floating-point
Character - String - nullptr (C++11)
User-defined (C++11)
Utilities
Attributes (C++11)
Types
typedef declaration
Type alias declaration (C++11)
Casts
Memory allocation
Classes
Class-specific function properties
Special member functions
Templates
Miscellaneous

以下是 C++ 中的标点符号。每个符号的具体含义详见链接页面。

目录

预处理运算符

预处理运算符由 预处理器 识别。

# (包括 % : )

## (包括 % : % :

单字符运算符与标点符

{ } (包括 < % % >

(自 C++11 起)
(C++20 起)

[ ] (包括 < : : > )

(since C++11)
(since C++17)
(since C++26)

( )

(自 C++11 起)
(since C++11)
(since C++17)
(since C++20)
(C++11 起)
  • 异常处理程序 中,分隔参数声明。
  • 函数式宏定义 中,分隔宏参数。
  • 函数式宏调用 中,分隔宏实参或防止逗号被解释为参数分隔符。
  • 作为 defined __has_include (C++17 起) __has_cpp_attribute (C++20 起) 预处理运算符的组成部分。
  • static_assert 声明中,分隔操作数。
  • 分隔以下说明符的操作数:
(C++20 起)
  • 属性 中,分隔属性参数。
(C++11 起)
(C++14 起)
(C++17 起)
  • 可变参数宏定义中 __VA_OPT__ 替换的组成部分。
(C++20 起)

;

  • 表示结束
(自 C++20 起)

:

(自 C++11 起)
(自 C++17 起)
(自 C++20 起)

?

.

(since C++20)

~ (包括 compl

! (包括 not

(since C++23)

+

-

*

  • lambda 捕获 列表中的 * this 部分,用于通过复制捕获当前对象。
(since C++17)

/

%

^ (包括 xor )

& (包含 bitand

(since C++11)

| (包括 bitor

=

(C++11 起)
(C++20 起)

<

(自 C++20 起)
(since C++17)
(since C++20)

>

(自 C++20 起)
(since C++17)
(since C++20)

,

(since C++11)
(since C++17)
(since C++23)
(自 C++11 起)

多字符运算符与标点符

...

(C++11 起)
(C++26 起)

::

  • 作用域解析运算符在
  • 属性 中,指示属性作用域。
(since C++11)
(since C++17)

. *

- >

(since C++11)
(since C++17)
(since C++20)

- > *

+ =

- =

* =

/ =

% =

^ = (包括 xor_eq )

& = (包含 and_eq

| = (包含 or_eq

==

! = (包括 not_eq

<=

>=

<=>

(自 C++20 起)

&& (包括 and )

  • 声明符或类型标识中的右值引用运算符。
  • 成员函数声明中的引用限定符。
(since C++11)

|| (包含 or )

<<

>>

<<=

>>=

++

--

参考文献

  • C++23 标准 (ISO/IEC 14882:2024):
  • 5.12 运算符与标点符 [lex.operators]
  • C++20 标准 (ISO/IEC 14882:2020):
  • 5.12 运算符与标点符号 [lex.operators]
  • C++17 标准 (ISO/IEC 14882:2017):
  • 5.12 运算符与标点符号 [lex.operators]
  • C++14 标准 (ISO/IEC 14882:2014):
  • 2.13 运算符与标点符号 [lex.operators]
  • C++11 标准 (ISO/IEC 14882:2011):
  • 2.13 运算符与标点符号 [lex.operators]
  • C++03 标准 (ISO/IEC 14882:2003):
  • 2.12 运算符与标点符号 [lex.operators]
  • C++98 标准 (ISO/IEC 14882:1998):
  • 2.12 运算符与标点符号 [lex.operators]

参见

替代表示法 特定运算符的替代拼写
C 文档 关于 标点符号