Article View: gnu.g++.bug
Article #957template <class T, T ...> important!
From: David Kastrup
Date: Mon, 14 Sep 1992 20:17
Date: Mon, 14 Sep 1992 20:17
33 lines
1736 bytes
1736 bytes
There was some discussion going on whether the above construction was legal. Although it is not explicitly stated in ARM, it is a very important construction, because: Templates cannot be nested. Suppose you have a sort template that should work as fast as possible on linked lists. It would look something like: template <class T, T * T::*link> You could modify the link parameter to be a parameter for the subroutine, but then you are replacing a compile time constant by a variable which would usually assume one value anyhow. Consider defining a Fourier transform working on arbitrary fields with roots of 1. Then you could use something like template <class Field, unsigned N, Field * Nthroot> and use it something like Complex const NR = exp(2*pi*Complex(0,1)/N); fft<Complex, 1024, &NR>.transform(... or Modular<64513> NR = 9; //Value is wrong fft<Modular<64513>, 1024, &NR>.transform(... Although it would work with complex numbers just as fast as usual, it would without modification work even faster with other fields as a base. Other classes and functions might need other information necessarily not included in the basic type, but being constant. PLEASE let the template scopes begin immediately after their declaration, not after the closing >.
Technical Details
Message-ID:
<9209141617.AA01219@messua>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pool.INformatik.rwth-aachen.DE!dakShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!pool.INformatik.rwth-aachen.DE!dak From: dak@pool.INformatik.rwth-aachen.DE (David Kastrup) Subject: template <class T, T ...> important! Message-ID: <9209141617.AA01219@messua> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Mon, 14 Sep 1992 20:17:51 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 34