forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc-style-math-functions.qhelp
48 lines (36 loc) · 1.17 KB
/
c-style-math-functions.qhelp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>The C++ standard library provides a large selection of math functions.
These functions are available for use either in the std namespace or in the global namespace.</p>
<p>In order to highlight invocations of the standard library and avoid occasional
definitional differences of these functions, we prefer to avoid use of the functions in the global namespace.</p>
</overview>
<recommendation>
<p>Prefer to invoke the functions defined in the std namespace.</p>
</recommendation>
<example>
<p>Most current c++ standard libraries will allow invoking math functions in the global namespace</p>
<sample language="cpp">
#include <cmath>
float my_pow( float base, float exp ) {
return pow( base, exp );
}
</sample>
<p>Prefer invoking the version in the std namespace.</p>
<sample language="cpp">
#include <cmath>
float my_pow( float base, float exp ) {
return std::pow( base, exp );
}
</sample>
</example>
<references>
<li>
Informative Stack Exchange Answer:
<a href="https://stackoverflow.com/a/8734292/280690">Differences between math.h and cmath</a>.
</li>
</references>
</qhelp>