Re: function template specialization problem

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

 




On 21 Mar, 2006, at 20:16, rodolfo@xxxxxxxxxxx wrote:

Hi, I don't know if this is a C++ or g++ problem, but this snippet
doesn't compile, but I think it should:

template <class T> void test(const char *par);

template <> void test<int>(const char *par = 0) {}

int main()
{
    test<int>();
}

g++ 3.4.5 returns the following errors:
test.cpp:3: error: default arguments are only permitted for function parameters
test.cpp:7: error: no matching function for call to `test()'

The first error message is unclear, but the code is illegal anyway. You cannot declare a default parameter in a specialization. You must declare it in the function template declaration, and only there.


[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