Where in the C++11 standard is std::fmodf stated?

148 views Asked by At

According to the cppref page, std::fmodf was added to cmath in C++11. How is this possible though, because wouldn't this mean that cmath would break compatability with math.h previous to C++11? I'm unable to find any references that say std::fmodf was added in C++11 and was wondering where this is stated.

Thank you

1

There are 1 answers

2
eerorika On BEST ANSWER

Where in the C++11 standard is std::fmodf stated?

It wasn't mentioned directly (although it probably should have been mentioned either in the list of functions, or explicitly omitted). The change that causes std::fmodf to exist is here (quote from draft N3337):

The following referenced documents are indispensable for the application of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.

  • ...
  • ISO/IEC 9899:1999, Programming languages — C
  • ...

Through the following rule:

[c.math]

The contents of these headers are the same as the Standard C library headers <math.h> and <stdlib.h> respectively, with the following changes: ...

C99 added fmodf. It was inherited to C++ when C++11 started referring to the standard library of C99 instead of C89.

Note, the "following changes" do not list omission of fmodf.


Why isn't fmodf listed in the list of functions (26.8/3 and 26.8/9)? It was added to the list in the C++17 standard.

This appears to have been an editorial mistake. It seems to have been fixed in C++17 by P0175 which proposes:

In this editorial paper we propose to add to the working draft the complete synopses of the C library headers that are included in C++ by reference to the C standard (see Table 15). These synopses will replace the various tables captioned “Header synopsis”.


Sidenote: std::fmodf is fairly useless in C++, since you can simply use std::fmod instead, and that has been around since C++98.