(ref.doc)fjh 260194

Next bs 240194 Prev: kanze 200194 Up: Usenet

Newsgroups: comp.lang.c++  (Note:
 Henderson)
Subject: Re: Inheritance and Templates
Organization: Computer Science, University of Melbourne, Australia
Date: Wed, 26 Jan 1994 16:10:17 GMT

[email protected] (Volker Stahl) writes:

>Is the following program correct? 
>It compiles with IBM xlC but gnu c++ requires explicit casting.
>
>template <class T> class Parent { };
>template <class T> class Child : public Parent<T> { };
>template <class T> void fun(const Parent<T> &);
>
>main() {
>  Child<int> c;
>  fun(c);
>}

According to the ARM, this program is not correct, because the call
requires a conversion from a derived class to a to reference to the
base class, and that conversion is not a trivial conversion.  However
Paul Lucas has recently posted here saying that the C++ committee has
relaxed the rules so that these conversions will be allowed in calls to
template functions.  This means that your code will be ANSI/ISO C++
conformant, but it's not ARM-conformant.

automatically generated by info2www version 1.2.2.8