Topic: type conversion in template functions
Author: 100754.2730@compuserve.com (Martin Aupperle)
Date: 1996/05/21 Raw View
To my knowledge, if I have
template< class T> void f( T, T );
not even the slightest conversions are allowed when instantiating f.
It is an error to say
int i=0;
const int j=1;
f( i, j );
Now, I heard that something has been changed in this area. Is the rule
still so strict? Or are "trivial conversions" (e.g. doing away the
cv-qualifiers) now allowed?
Thank you - Martin
-----------------------------------
Signatures are a waste of bandwidth
-----------------------------------
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: jason@cygnus.com (Jason Merrill)
Date: 1996/05/21 Raw View
>>>>> Martin Aupperle <100754.2730@compuserve.com> writes:
> To my knowledge, if I have
> template< class T> void f( T, T );
> not even the slightest conversions are allowed when instantiating f.
> It is an error to say
> int i=0;
> const int j=1;
> f( i, j );
> Now, I heard that something has been changed in this area. Is the rule
> still so strict? Or are "trivial conversions" (e.g. doing away the
> cv-qualifiers) now allowed?
The notion of 'trivial conversions' is no longer part of the standard, but
yes, this example is now allowed.
5 A template type argument T or a template non-type argument i can be
deduced if P and A have one of the following forms:
T
cv-list T
T*
T&
T[integer-constant]
class-template-name<T>
type(*)(T)
T(*)()
T(*)(T)
type T::*
T type::*
T (type::*)()
type (T::*)()
type (type::*)(T)
type[i]
class-template-name<i>
Jason
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]