On 03/01/2013 05:15 AM, Ulrich Drepper wrote:
On Thu, Feb 21, 2013 at 12:38 PM, Benjamin De Kosnik <b...@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

Reply via email to