A
Adam
I'm trying to write a template specialization, and the char*
specialization is giving me some trouble. Here's a simplified example:
/**************************/
/* test.cpp */
#include "try.hpp"
int main(){}
/**************************/
/**************************/
/* try.hpp */
template <typename T> struct foo
{
void f(const T& param) const;
};
template <typename T>
void
foo<T>::f(const T& param) const
{}
template <> // works fine
void
foo<int>::f(const int& param) const
{}
/*
The following results in:
template-id `f<>' for `void foo<char*>::f(const char*&) const' does not
match any template declaration
template <>
void
foo<char*>::f(const char*& param) const
{}
*/
/*
The following results in:
template-id `f<>' for `void foo<char*>::f(const char*) const' does not
match any template declaration
template <>
void
foo<char*>::f(const char* param) const
{}
*/
/*
But the following works fine. That really confuses me....
*/
typedef char* Char;
template <>
void
foo<Char>::f(const Char& param) const
{}
/**************************/
Thanks for reading. Any help would be greatly appreciated.
- Adam
specialization is giving me some trouble. Here's a simplified example:
/**************************/
/* test.cpp */
#include "try.hpp"
int main(){}
/**************************/
/**************************/
/* try.hpp */
template <typename T> struct foo
{
void f(const T& param) const;
};
template <typename T>
void
foo<T>::f(const T& param) const
{}
template <> // works fine
void
foo<int>::f(const int& param) const
{}
/*
The following results in:
template-id `f<>' for `void foo<char*>::f(const char*&) const' does not
match any template declaration
template <>
void
foo<char*>::f(const char*& param) const
{}
*/
/*
The following results in:
template-id `f<>' for `void foo<char*>::f(const char*) const' does not
match any template declaration
template <>
void
foo<char*>::f(const char* param) const
{}
*/
/*
But the following works fine. That really confuses me....
*/
typedef char* Char;
template <>
void
foo<Char>::f(const Char& param) const
{}
/**************************/
Thanks for reading. Any help would be greatly appreciated.
- Adam