[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc
Subject:    Re: [Q] about template specialization
From:       Nathan Myers <ncm () cygnus ! com>
Date:       1998-04-27 22:31:35
[Download RAW message or body]

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic