From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nathan Myers To: egcs@cygnus.com Subject: Re: [Q] about template specialization Date: Mon, 27 Apr 1998 17:27:00 -0000 Message-id: <35450747.CDFAD8B8@cygnus.com> References: <354231E5.F2165C14@Shevchenko.Kiev.UA> X-SW-Source: 1998-04/msg01086.html Alexandre Oliva wrote: > > Ruslan Shevchenko writes: > > > template inline > > const K& default_key(const E&); > > > template inline > > const T& default_key(const T& x) > > > virtual const K& get_key(const E& x) > > { return default_key(x); } > > > I think that X::get_key must call specialization (i. e. second > > definition) > > There's not such thing as partial specialization of a function > templates. You have just overloaded `default_key' with two different > template functions. In this case, you will always have to explicitly > specify template arguments. Since you specify default_key, not > just default_key, you are selecting the first definition. When the specialization semantics of function templates are not what you want, you can use a function object to get a similar result. A function template can still be used for the interface. Nathan Myers ncm@cantrip.org