This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
explicit specialization in non-namespace scope
- From: "Sujatha, Narayanan (IE10)" <Sujatha dot Narayanan at honeywell dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Mon, 16 Jun 2003 23:20:54 -0700
- Subject: explicit specialization in non-namespace scope
> 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