468,456 Members | 1,843 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,456 developers. It's quick & easy.

predicates,

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
4 1333
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

"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
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
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.

Similar topics

2 posts views Thread by Thong Nguyen | last post: by
reply views Thread by dayzman | last post: by
1 post views Thread by Trent Buck | last post: by
2 posts views Thread by Markus Neifer | last post: by
1 post views Thread by David Veeneman | last post: by
4 posts views Thread by Arun Srinivasan | last post: by
1 post views Thread by subhajit12345 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.