From 3255075171363144933
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,703e6c6373b79cbc
X-Google-Attributes: gidf78e5,public
From: Valentin Bonnard <bonnardv@pratique.fr>
Subject: Re: Proposal for generalization of void *
Date: 1998/03/03
Message-ID: <34FBFB10.11BE@pratique.fr>#1/1
X-Deja-AN: 330436616
Content-Transfer-Encoding: 7bit
References: <34F82AF1.7955@ibm.net> <34FAEBF8.4638B5B0@physik.tu-muenchen.de>
X-Original-Date: Tue, 03 Mar 1998 13:44:00 +0100
Content-Type: text/plain; charset=us-ascii
Organization: Ecole Normale Superieure, Paris, France
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANPwmD+EDnX0m9pzZAQFmwAF+NfncNzVSxQ4Um9PL/TU6Gz+NsPZE7n6O RvNiKW9IpL2sc4T/NOPdlne5GgPBTp3q =DEOi
Mime-Version: 1.0
Newsgroups: comp.std.c++


Christopher Eltschka wrote:
> 
> Walter W. Karas wrote:

> [... description of inert<> ...]
> 
> I don't think this would be a good idea. A better idea would be to
> write compilers which automatically reuse template instantiations
> with equal properties.

Right

> The only problem I see is that the standard AFAIK mandates different
> addresses for different functions, and different template instantiations
> _are_ different functions, even if their code is bitwise identical.

assert (sizeof (int) == sizeof (long));

template <class T>
T   prod(T lhs, T rhs>
{
    return lhs * rhs;
}

int x;
long y;

prod (3, x) + prod (4L, y);

assert (&prod<int> != &prod<long>); // no ! type mismatch

The linker just as to see that:
- both prod<int> and prod<long> have the same code
- they have different types, so one can't compare 
  their addresses

The linker should learn C++ anyway.

-- 

Valentin Bonnard                mailto:bonnardv@pratique.fr
info about C++/a propos du C++: http://pages.pratique.fr/~bonnardv/
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



