mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 20:54:41 +03:00
Issue 660
Note added
This commit is contained in:
@@ -2229,7 +2229,8 @@ The (in)famous factorial:
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
This is C++14. For C++11, use a recursive formulation of `fac()`.
|
This is C++14.
|
||||||
|
For C++11, use a recursive formulation of `fac()`.
|
||||||
|
|
||||||
##### Note
|
##### Note
|
||||||
|
|
||||||
@@ -2259,6 +2260,12 @@ it just guarantees that the function can be evaluated at compile time for consta
|
|||||||
|
|
||||||
This is usually a very good thing.
|
This is usually a very good thing.
|
||||||
|
|
||||||
|
When given a non-constant argument, a `constexpr` function can throw.
|
||||||
|
If you consider exiting by throwing a side-effect, a `constexpr` function isn't completely pure;
|
||||||
|
if not, this is not an issue.
|
||||||
|
??? A question for the committe: can a constructor for an exception thrown by a `constexpr` function modify state?
|
||||||
|
"No" would be a nice answer that matches most practice.
|
||||||
|
|
||||||
##### Note
|
##### Note
|
||||||
|
|
||||||
Don't try to make all functions `constexpr`.
|
Don't try to make all functions `constexpr`.
|
||||||
@@ -2439,6 +2446,12 @@ Pure functions are easier to reason about, sometimes easier to optimize (and eve
|
|||||||
|
|
||||||
`constexpr` functions are pure.
|
`constexpr` functions are pure.
|
||||||
|
|
||||||
|
When given a non-constant argument, a `constexpr` function can throw.
|
||||||
|
If you consider exiting by throwing a side-effect, a `constexpr` function isn't completely pure;
|
||||||
|
if not, this is not an issue.
|
||||||
|
??? A question for the committe: can a constructor for an exception thrown by a `constexpr` function modify state?
|
||||||
|
"No" would be a nice answer that matches most practice.
|
||||||
|
|
||||||
##### Enforcement
|
##### Enforcement
|
||||||
|
|
||||||
Not possible.
|
Not possible.
|
||||||
|
|||||||
Reference in New Issue
Block a user