public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Partial specialization
@ 1997-09-02  8:34 Stefan Meixner
  0 siblings, 0 replies; only message in thread
From: Stefan Meixner @ 1997-09-02  8:34 UTC (permalink / raw)
  To: EGCS

While testing the 970828 egcs snapshot I ran across
a 'bug' with the partial template specialization 
implementation. I was testing g++ with the Blitz++
library, testing for the partial specialization
ability of g++. g++ is not able to compile
the following code example

-----------------------------------------------------------
// Partial specialization

template<class T_type, int N>
class foo {
public:
  enum bar { z = 0 };
};

template<int N>
class foo<double, N> {
public:
  enum bar { z = 1 };
};

template<class T_type>
class foo<T_type, 2> {
public:
  enum bar { z = 2 };
};

int main()
{
    if ((foo<int,3>::z == 0) && (foo<double,3>::z == 1) 
       && (foo<float,2>::z == 2))
           return 0;
    else
        return 1;
}
-----------------------------------------------------------
g++ -c partial.cpp 
partial.cpp: In function `int main()':
partial.cpp:25: ambiguous class template instantiation for `class foo<float,2>'
partial.cpp:20: candidates are: class foo<T_type,2>
partial.cpp:14:                 class foo<double,N>
partial.cpp:25: incomplete type `foo<float,2>' does not have member `z

Changing float into char everything is working as expected.

Stefan

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-09-02  8:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-09-02  8:34 Partial specialization Stefan Meixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).