Topic: template implications for deprecated float->int conversion
Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: Wed, 30 Mar 1994 17:29:50 GMT Raw View
b91926@fsgi01.fnal.gov (David Sachs) writes:
>This reminds me of another problem with Template functions. Suppose
>You have a section of code like this:
>
>...
>template <class T> inline T max(T a, T b)
>{
> return a>b?a:b;
>}
>
>long max(long, long);
>....
>
>
>What does the last declaration declare?
>
>A. An external function, long max(long,long)
>
>-- or ---
>
>B. Instantiate the template function max<long> and allow
>conversion of its arguments.
ARM 14.4: "Declaring a functino with the same name as a functino
template with a matching type constitutes a declaration of
a specific template function". What does this mean? Well,
it means that the compiler will decide at link time which
of (A) and (B) is correct. If a definition of an external
function `long max(long,long)' is found at link-time, then
that function is considered a template specialization, otherwise
code will be generated using the template.
--
Fergus Henderson - fjh@munta.cs.mu.oz.au
Author: grumpy@cbnewse.cb.att.com (Paul J Lucas)
Date: Fri, 25 Mar 1994 17:03:18 GMT Raw View
Author: bs@alice.att.com (Bjarne Stroustrup)
Date: 26 Mar 94 13:58:24 GMT Raw View
Article 7478 of 7482, Sat 13:48.
Subject: Re: template implications for deprecated float->int conversion
maxtal@physics.su.OZ.AU (John Max Skaller @ School of Physics, University of Sydney, Australia) writes
> >> In article <CMI5r7.26q@cbnewse.cb.att.com> grumpy@cbnewse.cb.att.com (Paul J Lucas) writes:
> >>> I just finished reading Bjarne's paper, "New Casts Revisited";
> >>> specifically, Chapter 20, "Deprecated Features." There is says
> >>> that conversions from floating-point to integer are deprecated.
>
> ...
>
> Well, Bjarnes book is wrong. Presumably because the text
> was written in expectation of a vote to deprecate such conversions.
Please note that Paul was referring to a PAPER I wrote for the committee.
It contained a proposal and only part of that proposal was accepted.
He did not refer to any of my BOOKs.
I try very hard to be accurate in my writings and to the best of my
knowledge I have never written anything depending on the expected
outcome of a vote (maybe something on the form ``the following will
be voted on at such and such meeting ...'' which does not mislead).
Also, none of my books have a chapter 20.
Statements of the form ``X's book is wrong'' cast seriously doubt on
``X's book'' as a source of information so please be very careful with
such statements.
- Bjarne
Author: grumpy@cbnewse.cb.att.com (Paul J Lucas)
Date: Sat, 19 Mar 1994 03:12:12 GMT Raw View
Author: maxtal@physics.su.OZ.AU (John Max Skaller)
Date: Sat, 19 Mar 1994 18:48:52 GMT Raw View
In article <CMw68G.73r@cbnewse.cb.att.com> grumpy@cbnewse.cb.att.com (Paul J Lucas) writes:
>From article <CMqqLB.E5v@ucc.su.OZ.AU>, by maxtal@physics.su.OZ.AU (John Max Skaller):
>> In article <CMI5r7.26q@cbnewse.cb.att.com> grumpy@cbnewse.cb.att.com (Paul J Lucas) writes:
>>> I just finished reading Bjarne's paper, "New Casts Revisited";
>>> specifically, Chapter 20, "Deprecated Features." There is says
>>> that conversions from floating-point to integer are deprecated.
>>> Does this mean that:
>>>
>>> template<class T> T Max( T, T );
>>>
>>> int i = 1;
>>> double d = 2.0;
>>>
>>> double m = Max( i, d );
>>>
>>> will now work because the only sensible thing to do is to
>>> promote 'i' to double?
>>
>> Doesnt matter. Deprecation of old style casts was rejected.
>
> And what's that got to do with anything?
Well, Bjarnes book is wrong. Presumably because the text
was written in expectation of a vote to deprecate such conversions.
But the resolution on new style casts explicitly doesnt
deprecate any old style casts at all. That may change before
the Standard is published.
--
JOHN (MAX) SKALLER, INTERNET:maxtal@suphys.physics.su.oz.au
Maxtal Pty Ltd, CSERVE:10236.1703
6 MacKay St ASHFIELD, Mem: SA IT/9/22,SC22/WG21
NSW 2131, AUSTRALIA
Author: akishor@a.cs.okstate.edu (AGRAWAL KISHOR SAT)
Date: Sun, 20 Mar 94 20:44:26 GMT Raw View
I have a stupid question regarding array of classes.
There is an array of student class.
class comp{
private:
element student[20];
....
};
There is an another class which holds a student's information such as
its name.
class element{
private:
char *name;
....
};
Say if I have to assign Joe's information (stored in the element class) to the
student[2], in what way I can do this.
- A C++ learner.
Author: b91926@fsgi01.fnal.gov (David Sachs)
Date: 20 Mar 1994 18:07:02 -0600 Raw View
This reminds me of another problem with Template functions. Suppose
You have a section of code like this:
...
template <class T> inline T max(T a, T b)
{
return a>b?a:b;
}
long max(long, long);
....
What does the last declaration declare?
A. An external function, long max(long,long)
-- or ---
B. Instantiate the template function max<long> and allow
conversion of its arguments.
Author: grumpy@cbnewse.cb.att.com (Paul J Lucas)
Date: Fri, 11 Mar 1994 13:35:23 GMT Raw View
I just finished reading Bjarne's paper, "New Casts Revisited";
specifically, Chapter 20, "Deprecated Features." There is says
that conversions from floating-point to integer are deprecated.
Does this mean that:
template<class T> T Max( T, T );
int i = 1;
double d = 2.0;
double m = Max( i, d );
will now work because the only sensible thing to do is to
promote 'i' to double?
--
- Paul J. Lucas
AT&T Bell Laboratories
Naperville, IL
Author: maxtal@physics.su.OZ.AU (John Max Skaller)
Date: Wed, 16 Mar 1994 04:46:23 GMT Raw View
In article <CMI5r7.26q@cbnewse.cb.att.com> grumpy@cbnewse.cb.att.com (Paul J Lucas) writes:
> I just finished reading Bjarne's paper, "New Casts Revisited";
> specifically, Chapter 20, "Deprecated Features." There is says
> that conversions from floating-point to integer are deprecated.
> Does this mean that:
>
> template<class T> T Max( T, T );
>
> int i = 1;
> double d = 2.0;
>
> double m = Max( i, d );
>
> will now work because the only sensible thing to do is to
> promote 'i' to double?
Doesnt matter. Deprecation of old style casts was rejected.
--
JOHN (MAX) SKALLER, INTERNET:maxtal@suphys.physics.su.oz.au
Maxtal Pty Ltd, CSERVE:10236.1703
6 MacKay St ASHFIELD, Mem: SA IT/9/22,SC22/WG21
NSW 2131, AUSTRALIA