public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: cuni@programmazione.it To: gcc-gnats@gcc.gnu.org Subject: c++/6327: g++ problems where partial specializing nested templates Date: Tue, 16 Apr 2002 10:16:00 -0000 [thread overview] Message-ID: <20020416170928.8362.qmail@sources.redhat.com> (raw) >Number: 6327 >Category: c++ >Synopsis: g++ problems where partial specializing nested templates >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue Apr 16 10:16:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: g++ >Release: Thread model: single - gcc version 3.0 >Organization: >Environment: Mandrake 8.0 on AMD Athlon 800 >Description: It seems that the compiler doesn't use correctly partial specialization of a nested template, even if it produce correct code when template are not nested. >How-To-Repeat: #include <typeinfo> #include <iostream> // generic template template<class T> struct Array_traits { template<class U> struct Rebind { typedef U Type; }; }; // partial specialization for arrays template<class T, int N> struct Array_traits<T[N]> { template<class U> struct Rebind { typedef Array_traits<T>::Rebind<U>::Type Type[N]; }; }; int main() { typedef int array_of_int[10][20][30]; Array_traits<array_of_int>::Rebind<float>::Type array_of_float; // it prints out A10_A20_A30_i std::cout << typeid(array_of_int).name() << std::endl; // it should print A10_A20_A30_f, but it prints A10_f std::cout << typeid(array_of_float).name() << std::endl; } >Fix: Here is a work-around that doesn't use nested templates: // generic template template<class T, class U> struct Array_rebind { typedef U Type; }; // partial specialization template<class T, int N, class U> struct Array_rebind<T[N], U> { typedef Array_rebind<T,U>::Type Type[N]; }; >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-04-16 17:16 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-04-16 10:16 cuni [this message] 2002-04-16 18:51 rodrigc
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020416170928.8362.qmail@sources.redhat.com \ --to=cuni@programmazione.it \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).