Topic: invlid explicit specialization nested template class when outer unspecialized
Author: Larry Evans <cppljevans@gmail.com>
Date: Sat, 30 Jan 2010 09:59:36 CST Raw View
When #undef DUMMY_ARG1, the following code:
--{--cut here--
//#define DUMMY_ARG1
template
< typename Arg0_0
>
struct
level_0
{
template
< typename Arg1_0
#ifdef DUMMY_ARG1
, typename Arg1_1=void
#endif
>
struct
level_1
{
};
template
< //typename Arg1_0
#ifdef DUMMY_ARG1
typename Arg1_1
#endif
>
struct
level_1
< int //specialization on Arg1_0
#ifdef DUMMY_ARG1
, Arg1_1
#endif
>
{
};
};
--}--cut here--
when compiled with gcc4.5, produces errors:
--{--cut here--
x.cpp:24:7: error: explicit specialization in non-namespace scope
'struct level_0<Arg0_0>'
x.cpp:26:5: error: template parameters not used in partial
specialization:
x.cpp:26:5: error: 'Arg0_0'
--}--cut here--
However, when #define DUMMY_ARG1, no errors occur.
It seems a waste to have to provide a dummy template argument
to workaround this limitation.
What's the rationale for this limitation on nested class template
specialization?
-regards,
Larry
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]