473,473 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

about unary_function

Hello everyone,
I am wondering what is the practical usage of unary_function? Could
anyone list some practical benefits?

My question is, a class like

class Foo : public std::unary_function<class A, class B>

is always the same (could use similar implementation) to

template <class A, class Bclass Foo

So we could always use the alternative approach to replace
unary_function.
thanks in advance,
George
Dec 1 '07 #1
1 1560
On 2007-12-01 04:59:58 -0500, Li****@gmail.com said:
>
I am wondering what is the practical usage of unary_function? Could
anyone list some practical benefits?
std::unary_function provides two typedef nams that can be used by other
classes to determine the argument type and the result type of a class's
function call operator. For example, the standard library templates
std::negate and std::unary_negate use this information to determine the
argument type and return type of their own function call operators.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

Dec 1 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
0
by: kyo | last post by:
class A { public: int a; }; struct testfun1 : public unary_function<const A&, bool> { bool operator()(const A &) const {
2
by: Piotr | last post by:
I am reading Effective STL item 7 My understanding is, instead of doing this: tempate <typename T> struct DeleteObject: public unary_function<const T*, void> { void operator() (const T* ptr)...
3
by: Allerdyce.John | last post by:
I would like to know what is the advantage of inherit from unary_function template? For example, I have this in my code: What is the advantage of doing this: class Same :...
4
by: JustSomeGuy | last post by:
I have a situation where i have a class myClass and then I have a list of these classes. my question is... What is the proper way to impelment a list of the classes? I know I can instantiate...
75
by: Steven T. Hatton | last post by:
No, this is not a troll, and I am not promoting Java, C-flat, D, APL, Bash, Mathematica, SML, or LISP. A college teacher recently posted to this newsgroup regarding her observation that there has...
7
by: curious2007 | last post by:
Hello, I have the following code, but does not compile: #include <iostream> using namespace std; template<class Arg, class Result> struct unary_function {
6
by: jabbah | last post by:
Hi, im failing with my first try to use unary_function, i got something (which i partly borrowed from another forum): #include <algorithm> #include <functional> #include <iostream> using...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.