From Jason Turner

[meta.const.eval]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpp3guq0g7/{from.md → to.md} +24 -0
tmp/tmpp3guq0g7/{from.md → to.md} RENAMED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Constant evaluation context <a id="meta.const.eval">[[meta.const.eval]]</a>
2
+
3
+ ``` cpp
4
+ constexpr bool is_constant_evaluated() noexcept;
5
+ ```
6
+
7
+ *Returns:* `true` if and only if evaluation of the call occurs within
8
+ the evaluation of an expression or conversion that is manifestly
9
+ constant-evaluated [[expr.const]].
10
+
11
+ [*Example 1*:
12
+
13
+ ``` cpp
14
+ constexpr void f(unsigned char *p, int n) {
15
+ if (std::is_constant_evaluated()) { // should not be a constexpr if statement
16
+ for (int k = 0; k<n; ++k) p[k] = 0;
17
+ } else {
18
+ memset(p, 0, n); // not a core constant expression
19
+ }
20
+ }
21
+ ```
22
+
23
+ — *end example*]
24
+