Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > how to understand "u_long operator() (const KeyType kt) const"

Reply
Thread Tools

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

 
 
thomas
Guest
Posts: n/a
 
      02-14-2008
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?
 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      02-14-2008
* 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

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
an error on multi-source, but I can't understand... Neil VHDL 11 03-11-2010 03:15 PM
Read all of this to understand how it works. then check around on otherRead all of this to understand how it works. then check around on other thelisa martin Computer Support 2 08-18-2005 06:40 AM
understand Mozilla Thunderbird files... Joh Firefox 6 12-11-2004 11:46 PM
how to read and understand long written VHDL code? walala VHDL 6 09-03-2003 07:49 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57