explicit specialization in non-namespace scope
Sujatha, Narayanan (IE10)
Sujatha.Narayanan@honeywell.com
Mon Jun 16 15:09:00 GMT 2003
I am using gcc 3.1 compiler for power pc. I am getting the following errors
if I specialize member templates.
TEST_Stream_accessor.h:22: explicit specialization in non-namespace scope
`class TEST::Stream_accessor'
TEST_Stream_accessor.h:23: invalid use of undefined type `class
TEST::Stream_accessor'
TEST_Stream_accessor.h:9: forward declaration of `class
TEST::Stream_accessor'
TEST_Stream_accessor.h:24: confused by earlier errors, bailing out
Code Used:
namespace TEST
{
class Stream_accessor
{
public:
Stream_accessor();
virtual ~Stream_accessor();
template < class Stream >
static void create_stream(Stream * * stream_ptr)
{}
template < >
static void create_stream < std::istringstream > (std::istringstream
* * stream_ptr)
{
* stream_ptr = new std::istringstream();
}
};
}
I am getting "is not a valid type for a template constant parameter" if I
use the following syntax:
template < std::istringstream >
static void create_stream (std::istringstream * * stream_ptr)
{
* stream_ptr = new std::istringstream();
}
'struct std::basic_istringstream<char, std::char_traits<char>,
std::allocator<char> >' is not a valid type for a template constant
parameter
`struct std::basic_ostringstream<char, std::char_traits<char>,
std::allocator<char> >' is not a valid type for a template constant
parameter
`struct std::basic_ifstream<char, std::char_traits<char> >' is not a valid
type for a template constant parameter
`struct std::basic_ofstream<char, std::char_traits<char> >' is not a valid
type for a template constant parameter
Please tell me as to what the syntax should be to implement specializations
for member templates ( The first method works fine with MSVC compiler )
Thanks,
Sujatha
More information about the Gcc-help
mailing list