473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

inner template class specialization

Hi,

I need to specialize an inner template class, but gcc
refuses to compile. Here is a minimal example exposing the issue:

template<int astruct Outer {
template<int bstruct Inner {
};
};
template<int atemplate<struct Outer<a>::Inner<0{
};

gcc reports:

$ g++ -c inner.cc
inner.cc:5: error: invalid explicit specialization before ?>? token
inner.cc:5: error: enclosing class templates are not explicitly specialized
inner.cc:5: error: template parameters not used in partial specialization:
inner.cc:5: error: 'a'

Is this a gcc-specific bug or am I doing something wrong?

Thanks,

Christof
Jul 30 '08 #1
3 4258
Hi

Christof Warlich wrote:
$ g++ -c inner.cc
inner.cc:5: error: invalid explicit specialization before ?>? token
inner.cc:5: error: enclosing class templates are not explicitly
specialized inner.cc:5: error: template parameters not used in partial
specialization:
inner.cc:5: error: 'a'

Is this a gcc-specific bug or am I doing something wrong?
It's not a bug. You are not allowed to explicitly specialize the inner
template that way ("the declaration shall not explicitly specialize a class
member template if its enclosing class templates are not explicitly
specialized as well", 14.7.3/18)

Markus

Jul 30 '08 #2
Markus Moll schrieb:
It's not a bug. You are not allowed to explicitly specialize the inner
template that way ("the declaration shall not explicitly specialize a class
member template if its enclosing class templates are not explicitly
specialized as well", 14.7.3/18)
Does this mean that specialization of an inner class does not work at all?
I tried several things, but without success.

Nevertheless, your wording:
You are not allowed to explicitly specialize the inner template "that way"
gives me some hope that it _is_ possible. Any ideas how to do it right?

Thanks for any help,

Christof
Jul 30 '08 #3
Christof Warlich schrieb:
Nevertheless, your wording:
You are not allowed to explicitly specialize the inner template "that
way"

gives me some hope that it _is_ possible. Any ideas how to do it right?
Just found the solution myself:

template<int astruct Outer {
template<int b, int dummystruct Inner {
};
};
template<int a>
template<int dummy>
struct Outer<a>::Inner<0, dummy{
};

Again, thanks for your help, it just gave the hint that I was in need for :-).
Jul 30 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SainTiss | last post by:
Hi, If you've got a template class with lots of methods, and then you've got a type which works with the template, except for one method... What you need to do there is specialize the...
8
by: Agent Mulder | last post by:
Hi group, I have a problem with partial template specialization. In the code below I have a template struct Music with one method, play(), and three kinds of music, Jazz, Funk and Bach. When I...
2
by: Jeff | last post by:
/* -------------------------------------------------------------------------- Hello, I was experimenting with class templates and specializing member functions and came across a simple problem...
9
by: Marek Vondrak | last post by:
Hello. I have written the following program and am curious why it prints "1" "2". What are the exact effects of explicitly providing function template parameters at the call? Is the second...
2
by: Thomas Kowalski | last post by:
Hi, I would like to write a template class Polygon<VertexTypthere vertex typ can be eigther a pointer or a value typ. It has an attribute: std::vector<VertexTypvertices; And a methode:...
9
by: stephen.diverdi | last post by:
Can anyone lend a hand on getting this particular template specialization working? I've been trying to compile with g++ 4.1 and VS 2005. ...
2
by: Barry | last post by:
The following code compiles with VC8 but fails to compiles with Comeau online, I locate the standard here: An explicit specialization of any of the following:
8
by: flopbucket | last post by:
Hi, I want to provide a specialization of a class for any type T that is a std::map. template<typename T> class Foo { // ... };
6
by: abir | last post by:
i have a template as shown template<typename Sclass Indexer{}; i want to have a specialization for std::vector both const & non const version. template<typename T,typename Aclass...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.