fabsf是C ++ 11中std名称空间的一部分吗? [英] Is fabsf part of the std namespace in C++11?
问题描述
页面 https://en.cppreference.com/w/cpp / numeric / math / fabs 提到 std :: fabsf
自C ++ 11起可用。但是,当我使用G ++ 6.3.0甚至编译使用 std :: fabsf
的最简单程序时,它表示 fabsf
不是 std
的成员。
The page https://en.cppreference.com/w/cpp/numeric/math/fabs mentions that std::fabsf
is available since C++11. However, when I use G++ 6.3.0 to compile even the simplest program that uses std::fabsf
, it says that fabsf
is not a member of std
.
#include <cmath>
int main()
{
return (int)std::fabsf(0.0f);
}
哪个是对的? G ++ 6.3.0是否在不包含在 std
中是错误的,还是上述页面在将它作为 std $ c $的一部分提及时是错误的c>在C ++ 11中?
Which one is right? Is G++ 6.3.0 wrong in not including it in std
, or is the above page wrong in mentioning it as part of std
in C++11?
如果是G ++错误,在更高版本中是否已解决?
And if it's G++ that is wrong, is that fixed in later versions?
推荐答案
是的, fabsf
和所有其他 -f
/ <$来自 math.h 的c $ c> -l </ code>函数是
std
命名空间的一部分通过C ++ 11中的 cmath
它是在2002年左右添加的,当时C ++ 0x在C99标准库的基础上重新构建,该库使 [c.math] / 4
包括那些新功能。
Yes, fabsf
and all other -f
/-l
functions from math.h
is part of the std
namespace via cmath
in C++11. It was added in about 2002, when C++0x was rebased on top of the C99 standard library, which made [c.math]/4
include those new functions.
[c.math] / 4
内容这些标头中的所有标头与标准C库标头< math.h>
和< stdlib.h>
分别进行以下更改:
The contents of these headers are the same as the Standard C library headers <math.h>
and <stdlib.h>
respectively, with the following changes:
(历史记录:意图添加所有 -f
/ -l </ code>变体已在C ++ 03中出现,请参见 LWG289 )
(historical note: the intent to add all the -f
/-l
variants was already apparent in C++03, see LWG289)
但是,直到2016年,当
p0175r1 修复了所有此类表,使其与标准保持一致。
However, the table listing the contents of cmath was overlooked until 2016, when p0175r1 fixed all such tables to bring them in line with the standard.
p0175r1
对标准的影响
更改纯属社论。
这篇关于fabsf是C ++ 11中std名称空间的一部分吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!