Skip to content

Commit 3cf2c0e

Browse files
author
Colin Robertson
authored
Address complaint in cpp-docs 3554 (#3950)
1 parent 2bfb139 commit 3cf2c0e

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

docs/cpp/expressions-with-unary-operators.md

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,63 @@ ms.assetid: 1217685b-b85d-4b48-9ff4-d90f56a26c1b
99

1010
Unary operators act on only one operand in an expression. The unary operators are as follows:
1111

12-
- [Indirection operator (*)](../cpp/indirection-operator-star.md)
12+
- [Indirection operator (`*`)](../cpp/indirection-operator-star.md)
1313

14-
- [Address-of operator (&)](../cpp/address-of-operator-amp.md)
14+
- [Address-of operator (`&`)](../cpp/address-of-operator-amp.md)
1515

16-
- [Unary plus operator (+)](../cpp/unary-plus-and-negation-operators-plus-and.md)
16+
- [Unary plus operator (`+`)](../cpp/unary-plus-and-negation-operators-plus-and.md)
1717

18-
- [Unary negation operator (-)](../cpp/unary-plus-and-negation-operators-plus-and.md)
18+
- [Unary negation operator (`-`)](../cpp/unary-plus-and-negation-operators-plus-and.md)
1919

20-
- [Logical negation operator (!)](../cpp/logical-negation-operator-exclpt.md)
20+
- [Logical negation operator (`!`)](../cpp/logical-negation-operator-exclpt.md)
2121

22-
- [One's complement operator (~)](../cpp/one-s-complement-operator-tilde.md)
22+
- [One's complement operator (`~`)](../cpp/one-s-complement-operator-tilde.md)
2323

24-
- [Prefix increment operator (++)](../cpp/prefix-increment-and-decrement-operators-increment-and-decrement.md)
24+
- [Prefix increment operator (`++`)](../cpp/prefix-increment-and-decrement-operators-increment-and-decrement.md)
2525

26-
- [Prefix decrement operator (--)](../cpp/prefix-increment-and-decrement-operators-increment-and-decrement.md)
26+
- [Prefix decrement operator (`--`)](../cpp/prefix-increment-and-decrement-operators-increment-and-decrement.md)
2727

2828
- [Cast operator ()](../cpp/cast-operator-parens.md)
2929

3030
- [`sizeof` operator](../cpp/sizeof-operator.md)
3131

32-
- [`__uuidof` operator](../cpp/uuidof-operator.md)
33-
3432
- [`alignof` operator](../cpp/alignof-operator.md)
3533

34+
- [`noexcept` expression](../cpp/noexcept-cpp.md)
35+
3636
- [`new` operator](../cpp/new-operator-cpp.md)
3737

3838
- [`delete` operator](../cpp/delete-operator-cpp.md)
3939

4040
These operators have right-to-left associativity. Unary expressions generally involve syntax that precedes a postfix or primary expression.
4141

42-
The following are the possible forms of unary expressions.
43-
44-
- *postfix-expression*
45-
46-
- `++` *unary-expression*
47-
48-
- `--` *unary-expression*
49-
50-
- *unary-operator* *cast-expression*
51-
52-
- **`sizeof`** *unary-expression*
53-
54-
- `sizeof(` *type-name* `)`
55-
56-
- `decltype(` *expression* `)`
57-
58-
- *allocation-expression*
42+
## Syntax
5943

60-
- *deallocation-expression*
44+
*`unary-expression`*:\
45+
  *`postfix-expression`*\
46+
  **`++`** *`cast-expression`*\
47+
  **`--`** *`cast-expression`*\
48+
  *`unary-operator`* *`cast-expression`*\
49+
  **`sizeof`** *`unary-expression`*\
50+
  **`sizeof`** **`(`** *`type-id`* **`)`**\
51+
  **`sizeof`** **`...`** **`(`** *`identifier`* **`)`**\
52+
  **`alignof`** **`(`** *`type-id`* **`)`**\
53+
  *`noexcept-expression`*\
54+
  *`new-expression`*\
55+
  *`delete-expression`*\
56+
*`unary-operator`*: one of\
57+
  **`*`** **`&`** **`+`** **`-`** **`!`** **`~`**
6158

62-
Any *postfix-expression* is considered a *unary-expression*, and because any primary expression is considered a *postfix-expression*, any primary expressions is considered a *unary-expression* also. For more information, see [Postfix Expressions](../cpp/postfix-expressions.md) and [Primary Expressions](../cpp/primary-expressions.md).
59+
## Remarks
6360

64-
A *unary-operator* consists of one or more of the following symbols: `* & + - ! ~`
61+
Any *`postfix-expression`* is considered a *`unary-expression`*, and because any *`primary-expression`* is considered a *`postfix-expression`*, any *`primary-expression`* is considered a *`unary-expression`* also. For more information, see [Postfix expressions](../cpp/postfix-expressions.md) and [Primary expressions](../cpp/primary-expressions.md).
6562

66-
The *cast-expression* is a unary expression with an optional cast to change the type. For more information see [Cast Operator: ()](../cpp/cast-operator-parens.md).
63+
The *`cast-expression`* is a *`unary-expression`* with an optional cast to change the type. For more information, see [Cast operator: `()`](../cpp/cast-operator-parens.md).
6764

68-
An *expression* can be any expression. For more information, see [Expressions](../cpp/expressions-cpp.md).
65+
The *`noexcept-expression`* is a *`noexcept-specifier`* with a *`constant-expression`* argument. For more information, see [`noexcept`](../cpp/noexcept-cpp.md).
6966

70-
The *allocation-expression* refers to the **`new`** operator. The *deallocation-expression* refers to the **`delete`** operator. For more information, see the links earlier in this topic.
67+
The *`new-expression`* refers to the **`new`** operator. The *`delete-expression`* refers to the **`delete`** operator. For more information, see [`new` operator](../cpp/new-operator-cpp.md) and [`delete` operator](../cpp/delete-operator-cpp.md).
7168

7269
## See also
7370

74-
[Types of Expressions](../cpp/types-of-expressions.md)
71+
[Types of expressions](../cpp/types-of-expressions.md)

docs/cpp/noexcept-cpp.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
---
22
description: "Learn more about: noexcept (C++)"
33
title: "noexcept (C++)"
4-
ms.date: "11/19/2019"
4+
ms.date: 11/30/2021
55
f1_keywords: ["noexcept_cpp"]
66
ms.assetid: df24edb9-c6a6-4e37-9914-fd5c0c3716a8
77
---
8-
# noexcept (C++)
8+
# `noexcept` (C++)
99

1010
**C++11:** Specifies whether a function might throw exceptions.
1111

1212
## Syntax
1313

14-
> *noexcept-expression*:\
15-
>     **`noexcept`**\
16-
>     **noexcept(** *constant-expression* **)**
14+
*`noexcept-specifier`*:\
15+
  **`noexcept`**\
16+
  *`noexcept-expression`*\
17+
  **`throw`** **`(`** **`)`**\
18+
*`noexcept-expression`*:\
19+
  **`noexcept`** **`(`** *`constant-expression`* **`)`**
1720

1821
### Parameters
1922

20-
*constant-expression*<br/>
23+
*`constant-expression`*\
2124
A constant expression of type **`bool`** that represents whether the set of potential exception types is empty. The unconditional version is equivalent to `noexcept(true)`.
2225

2326
## Remarks
2427

25-
A *noexcept expression* is a kind of *exception specification*, a suffix to a function declaration that represents a set of types that might be matched by an exception handler for any exception that exits a function. Unary conditional operator `noexcept(`*constant_expression*`)` where *constant_expression* yields **`true`**, and its unconditional synonym **`noexcept`**, specify that the set of potential exception types that can exit a function is empty. That is, the function never throws an exception and never allows an exception to be propagated outside its scope. The operator `noexcept(`*constant_expression*`)` where *constant_expression* yields **`false`**, or the absence of an exception specification (other than for a destructor or deallocation function), indicates that the set of potential exceptions that can exit the function is the set of all types.
28+
A *`noexcept-expression`* is a kind of *exception specification*: a suffix to a function declaration that represents a set of types that might be matched by an exception handler for any exception that exits a function. Unary conditional operator `noexcept(constant_expression)` when *`constant_expression`* yields **`true`**, and its unconditional synonym **`noexcept`**, specify that the set of potential exception types that can exit a function is empty. That is, the function never throws an exception and never allows an exception to be propagated outside its scope. The operator `noexcept(constant_expression)` when *`constant_expression`* yields **`false`**, or the absence of an exception specification (other than for a destructor or deallocation function), indicates that the set of potential exceptions that can exit the function is the set of all types.
2629

27-
Mark a function as **`noexcept`** only if all the functions that it calls, either directly or indirectly, are also **`noexcept`** or **`const`**. The compiler does not necessarily check every code path for exceptions that might bubble up to a **`noexcept`** function. If an exception does exit the outer scope of a function marked **`noexcept`**, [std::terminate](../standard-library/exception-functions.md#terminate) is invoked immediately, and there is no guarantee that destructors of any in-scope objects will be invoked. Use **`noexcept`** instead of the dynamic exception specifier `throw()`, which is now deprecated in the standard. We recommended you apply **`noexcept`** to any function that never allows an exception to propagate up the call stack. When a function is declared **`noexcept`**, it enables the compiler to generate more efficient code in several different contexts. For more information, see [Exception specifications](exception-specifications-throw-cpp.md).
30+
Mark a function as **`noexcept`** only if all the functions that it calls, either directly or indirectly, are also **`noexcept`** or **`const`**. The compiler doesn't necessarily check every code path for exceptions that might bubble up to a **`noexcept`** function. If an exception does exit the outer scope of a function marked **`noexcept`**, [`std::terminate`](../standard-library/exception-functions.md#terminate) is invoked immediately, and there's no guarantee that destructors of any in-scope objects will be invoked. Use **`noexcept`** instead of the dynamic exception specifier `throw()`. The *dynamic exception specification*, or `throw(optional_type_list)` specification, was deprecated in C++11 and removed in C++17, except for `throw()`, which is an alias for `noexcept(true)`. We recommended you apply **`noexcept`** to any function that never allows an exception to propagate up the call stack. When a function is declared **`noexcept`**, it enables the compiler to generate more efficient code in several different contexts. For more information, see [Exception specifications](exception-specifications-throw-cpp.md).
2831

2932
## Example
3033

@@ -42,5 +45,5 @@ T copy_object(const T& obj) noexcept(std::is_pod<T>)
4245
4346
## See also
4447
45-
[Modern C++ best practices for exceptions and error handling](errors-and-exception-handling-modern-cpp.md)<br/>
46-
[Exception Specifications (throw, noexcept)](exception-specifications-throw-cpp.md)
48+
[Modern C++ best practices for exceptions and error handling](errors-and-exception-handling-modern-cpp.md)\
49+
[Exception specifications (`throw`, `noexcept`)](exception-specifications-throw-cpp.md)

0 commit comments

Comments
 (0)