From Jason Turner

[dcl.attr.assume]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp5yq3vkpf/{from.md → to.md} +37 -0
tmp/tmp5yq3vkpf/{from.md → to.md} RENAMED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Assumption attribute <a id="dcl.attr.assume">[[dcl.attr.assume]]</a>
2
+
3
+ The *attribute-token* `assume` may be applied to a null statement; such
4
+ a statement is an *assumption*. An *attribute-argument-clause* shall be
5
+ present and shall have the form:
6
+
7
+ ``` bnf
8
+ '(' conditional-expression ')'
9
+ ```
10
+
11
+ The expression is contextually converted to `bool` [[conv.general]]. The
12
+ expression is not evaluated. If the converted expression would evaluate
13
+ to `true` at the point where the assumption appears, the assumption has
14
+ no effect. Otherwise, the behavior is undefined.
15
+
16
+ [*Note 1*: The expression is potentially evaluated [[basic.def.odr]].
17
+ The use of assumptions is intended to allow implementations to analyze
18
+ the form of the expression and deduce information used to optimize the
19
+ program. Implementations are not required to deduce any information from
20
+ any particular assumption. — *end note*]
21
+
22
+ [*Example 1*:
23
+
24
+ ``` cpp
25
+ int divide_by_32(int x) {
26
+ [[assume(x >= 0)]];
27
+ return x/32; // The instructions produced for the division
28
+ // may omit handling of negative values.
29
+ }
30
+ int f(int y) {
31
+ [[assume(++y == 43)]]; // y is not incremented
32
+ return y; // statement may be replaced with return 42;
33
+ }
34
+ ```
35
+
36
+ — *end example*]
37
+