This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] C++ math constants
- From: Daniel Krügler <daniel dot kruegler at gmail dot com>
- To: Ulrich Drepper <drepper at gmail dot com>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 21 Feb 2013 18:01:44 +0100
- Subject: Re: [PATCH] C++ math constants
- References: <CAOPLpQdxQkFcUb6-us3gdzesTwx8MyzxccF_TTZvO3=E0A1xsw@mail.gmail.com>
2013/2/21 Ulrich Drepper <drepper@gmail.com>:
> How about the attached file as a start for <ext/math>. I used the
> constexpr approach (instead of function calls) and replicated the
> constants that are available in <math.h> in Unix.
1) In this case I miss the corresponding variable definitions, because
you violate the ODR, when you have something like the following:
#include <iostream>
template<class T>
void print(const T& t) { std::cout << t; }
int main() {
print(__math_constants<double>::__pi);
}
2) You need to use either braced initializers *or* using initializers
with equal, a parenthesized initializer isn't supported
(/brace-or-equal-initializer/).
- Daniel