This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Partial ordering bug (?) in egcs


Mark Mitchell wrote:
> 
> >>>>> "Thomas" == Thomas Kunert <kunert@physik.tu-dresden.de> writes:
> 
>     Thomas> Mark Mitchell wrote:
>     >>  >>>>> "Thomas" == Thomas Kunert <kunert@physik.tu-dresden.de>
>     >> writes:
>     >>
>     Thomas> Mark Mitchell wrote:
>     >> >> template<int N> class IndexPlaceholder { }; >> >>
>     >> template<class T, int N> class Array { }; >> >> // #1
>     >> template<class T1, class T2> void max(const T1& a, const >> T2&
>     >> b) { } >> >> // #2 template<class T_numtype, int N_rank, int
>     >> N_index> inline >> void max(const Array<T_numtype, N_rank>&
>     >> array, >> IndexPlaceholder<N_index>) { } >>
>     >>
>     Thomas> Unfortunately I don't have a copy of the FDIS, but the
>     Thomas> Nov. 97 WP says in 14.5.5.2 [temp.func.order]:
>     >>
>     Thomas> `const T2&' is not supposed to be the the "same as" but an
>     Thomas> "exact match" for `IndexPlaceholder<N_index>'.  In the
>     Thomas> example above you can choose an appropriate T2.  Hence I
>     Thomas> think #2 is more specialized than #1.
>     >>  I don't see the distinction.
> 
>     Thomas> "The same as" means identity. "Exact match" includes
>     Thomas> Identity, Lvalue Transformation and Qualification
>     Thomas> Adjustment (see 13.3.3.1.1 [over.ics.scs] ).
> 
> But that's overloading!  (You're talking about overloading ranks: the
> "Exact Match Rank" in particular.)  We're not dealing with overloading
> here; we're dealing with template specialization.
> 
>     >> Are you proposing that, for example,
>     >>
>     >> template <class T> void f(const T&); template <> void f(int);
>     >>
>     >> is a legal specialization?  It's not, IMO.  But that would seem
>     >> to be the consequence of your suggestion.
> 
>     Thomas> I don't see the connection between these topics, can you
>     Thomas> elaborate on that?  Explicit specialization (as well as
> 
> To figure out what arguments are used for an explicit specialization
> you must perform argument deduction.  To determine which of two
> templates is more specialized you must perform argument deduction.
> So, if you can deduce a type for T2 such that `const T2&' is an "exact
> match" for `IndexPlaceholder<N_index>' you should be able to find one
> in my example as well.  And then, `template <> void f(int)' would be a
> legal specialization.

I see. You don't distinguish between argument deduction for explicit
specialization and argument deduction regarding partial ordering of
function templates. I was under the impression that the latter has more
relaxed rules:
Explicit specialization requires *identity*, partial ordering only an
*exact match*, e.g. `const IndexPlaceholder<N_index>&' is not of
identical type but an exact match for `IndexPlaceholder<N_index>'. I see
some advantages in my interpretation:
+ some useful constructs are supported (e.g. Todd's example)
+ it's portabel  :-)

Are there examples that wouldn't work with my point of view?

--
Thomas Kunert


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]