This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Vector Extensions in GCC
- To: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Subject: Re: Vector Extensions in GCC
- From: Gabriel Dos Reis <Gabriel dot Dos-Reis at cmla dot ens-cachan dot fr>
- Date: 12 Jul 2001 11:21:22 +0200
- Cc: Mark Mitchell <mark at codesourcery dot com>, Stan Shebs <shebs at apple dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Organization: CMLA, ENS Cachan -- CNRS UMR 8536 (France)
- References: <Pine.LNX.4.33.0107120950450.18533-100000@kern.srcf.societies.cam.ac.uk>
"Joseph S. Myers" <jsm28@cam.ac.uk> writes:
| On Thu, 12 Jul 2001, Mark Mitchell wrote:
|
| > template <typename T> T acos (T);
| > template <> double acos(double d) { return cos (d); }
| > template <> float acos(float f) { return cosf (f); }
| > template <> long double acos(long double l) { return cosl (l); }
|
| You then need to handle integer types, and complex types, and functions
| with more than one argument have correspondingly larger collections of
| specializations.
That is no more work you would have to do with overloading.
Furthermore, with just overloading you will have to duplicate codes
where templates just let you write it once.
When we have to invent extensions to solve some problems, we need to
have a larger view and see what mechanisms closely related languages
provide to solve the same set of problems and where they are heading.
In this particular case, a subset of C++ template is sufficiently
orthogonal to be added as pure extension to C, and it solves a larger
set of problems than sole overloading does.
-- Gaby