This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] C++ math constants
- From: Florian Weimer <fweimer at redhat dot com>
- To: Ulrich Drepper <drepper at gmail dot com>
- Cc: Benjamin De Kosnik <bkoz at redhat dot com>, Daniel KrÃgler <daniel dot kruegler at gmail dot com>, "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: Fri, 01 Mar 2013 09:51:47 +0100
- Subject: Re: [PATCH] C++ math constants
- References: <CAOPLpQdxQkFcUb6-us3gdzesTwx8MyzxccF_TTZvO3=E0A1xsw@mail.gmail.com> <CAGNvRgAf8oNHAcORU-RapgTWep9fYWcf=Z7d5OvP2zbYstu3dg@mail.gmail.com> <20130221093859.33b4d2fe@oakwood> <CAOPLpQfyDy1xmiR3E7z1_o0UsNbf_45CXT7-Fbx_FvsCiQ=HfA@mail.gmail.com>
On 03/01/2013 05:15 AM, Ulrich Drepper wrote:
On Thu, Feb 21, 2013 at 12:38 PM, Benjamin De Kosnik <bkoz@redhat.com> wrote:
Not seeing it.
Say for:
#include <iostream>
// A class for math constants.
template<typename _RealType>
struct __math_constants
{
// Constant @f$ \pi @f$.
static constexpr _RealType __pie =
3.1415926535897932384626433832795029L; };
template<class T>
void print(const T& t) { std::cout << t; }
int main()
{
print(__math_constants<double>::__pie);
return 0;
}
I'm not getting any definition, even at -O0.
Even more so: how would an explicit instantiation even work?
You don't need an explicit instantiation, just a regular templated
definition. This example shows that a definition is needed, and how one
is provided.
template <class T>
struct a {
static constexpr T m = T(1);
};
template <class T>
constexpr T a<T>::m;
const int *
f()
{
return &a<int>::m;
}
int
main()
{
return f() == 0;
}
--
Florian Weimer / Red Hat Product Security Team