how to understand "u_long operator() (const KeyType kt) const"

T

thomas

any ideas for this one?

--code--
template<>
class ACE_Hash<KeyType>
{
public:
u_long operator() (const KeyType kt) const
{
int val = kt;
return (u_long)val;
}
};
--code--

while "operator u_long (void) const; " may be easily understood as a
conversion operator;
what does "u_long operator() (const KeyType kt) const;" mean?
 
A

Alf P. Steinbach

* thomas:
any ideas for this one?

--code--
template<>
class ACE_Hash<KeyType>
{
public:
u_long operator() (const KeyType kt) const
{
int val = kt;
return (u_long)val;
}
};
--code--

while "operator u_long (void) const; " may be easily understood as a
conversion operator;
what does "u_long operator() (const KeyType kt) const;" mean?

'operator()' is the function call operator.

Given


KeyType const key = ...;
ACE_Hash<KeyType> hash;

you can use the hash object as a function

u_long const x = hash( key );

in order to obtain the result of first converting key to int and then
further to u_long, whatever that type is.


Cheers, & hth.,

- Alf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top