By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,305 Members | 1,657 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

predicates,

P: n/a
Why derive from: binary_function? It seems like that class just does some
typedefs.

For example, in Stroustrup (pg. 517 3rd edition):

class Club_eq : public unary_function<Club, bool{
string s;
public:
explicit Club_eq(const string& ss) : s(ss) {}
bool operator()(const Club& c) const { return c.name == s; }
};

He still uses "Club" and "bool" instead of the typdefed argument_type and
result_type. So what is the point of these base classes?
Jul 2 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
vsgdp wrote:
Why derive from: binary_function? It seems like that class just does
some typedefs.
You've answered your own question, I believe.
[..]
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 2 '06 #2

P: n/a

"Victor Bazarov" <v.********@comAcast.netwrote in message
news:Kd******************************@comcast.com. ..
vsgdp wrote:
>Why derive from: binary_function? It seems like that class just does
some typedefs.

You've answered your own question, I believe.
No, what is the point of the typedefs?
Jul 2 '06 #3

P: n/a
TB
vsgdp skrev:
"Victor Bazarov" <v.********@comAcast.netwrote in message
news:Kd******************************@comcast.com. ..
>vsgdp wrote:
>>Why derive from: binary_function? It seems like that class just does
some typedefs.
You've answered your own question, I believe.

No, what is the point of the typedefs?

For example, the typedefs are used to propagate type data
within template expansions.

--
TB @ SWEDEN
Jul 2 '06 #4

P: n/a
In article <GKUpg.170$5K2.84@fed1read03>, he***@null.com says...
Why derive from: binary_function? It seems like that class just does some
typedefs.

For example, in Stroustrup (pg. 517 3rd edition):

class Club_eq : public unary_function<Club, bool{
string s;
public:
explicit Club_eq(const string& ss) : s(ss) {}
bool operator()(const Club& c) const { return c.name == s; }
};

He still uses "Club" and "bool" instead of the typdefed argument_type and
result_type. So what is the point of these base classes?
The typedefs aren't (at least primarily) for the benefit of the code
in the predicate itself. Rather, they're for use by the code in the
algorithm(s) to which you pass the predicate as an argument. The
typedefs give that code information about your predicate so the
predicate can be used correctly.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 3 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.