public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathan Myers <ncm@cygnus.com>
To: egcs@cygnus.com
Subject: Re: [Q] about template specialization
Date: Mon, 27 Apr 1998 17:27:00 -0000	[thread overview]
Message-ID: <35450747.CDFAD8B8@cygnus.com> (raw)
In-Reply-To: <orlnsrvlnc.fsf.cygnus.egcs@garnize.lsd.dcc.unicamp.br>

Alexandre Oliva wrote:
> 
> Ruslan Shevchenko <Ruslan@Shevchenko.Kiev.UA> writes:
> 
> > template<class K, class E> inline
> > const K& default_key(const E&);
> 
> > template<class T> inline
> > const T& default_key(const T& x)
> 
> >    virtual const K& get_key(const E& x)
> >     { return  default_key<K,E>(x); }
> 
> > I think  that  X<Y,Y>::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<K,E>, not
> just default_key<K>, 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

      parent reply	other threads:[~1998-04-27 17:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-25 11:59 Ruslan Shevchenko
1998-04-27  0:33 ` Alexandre Oliva
     [not found] ` <orlnsrvlnc.fsf.cygnus.egcs@garnize.lsd.dcc.unicamp.br>
1998-04-27 17:27   ` Nathan Myers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=35450747.CDFAD8B8@cygnus.com \
    --to=ncm@cygnus.com \
    --cc=egcs@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).