Re: Incorrect (?) template specialization results when compiling with -O3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrew Bell wrote:

But int your example, isn't the <int> specialization visible at the
point the call is made - even if it is through the header file?

No. The header file did not declare the specialization, so the specialization was called without being declared.

I think you only need to declare it, not define it, in the compilation where it is called (though one of the posts in that link said otherwise). Change the header file to

// Binky.h
#ifndef BINKY_H
#define BINKY_H
template<typename T> const char* getString()
{
   return "T";
}
template<> const char* getstring<int>();
#endif





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux