<functional>binary_function · binary_negate
· binder1st
· binder2nd
· divides
· equal_to
· greater
· greater_equal
· less · less_equal
· logical_and
· logical_not
· logical_or
· mem_fun_t
· mem_fun_ref_t
· mem_fun1
· mem_fun1_ref_t
· minus ·
modulus
· multiplies
· negate
· not_equal_to
· plus · pointer_to_binary_function
· pointer_to_unary_function
· unary_function
· unary_negate
bind1st
· bind2nd
· mem_fun
· mem_fun_ref
· mem_fun1
· mem_fun1_ref
· not1 · not2 · ptr_fun
namespace std {
// TEMPLATE CLASSES
template<class Arg, class Result>
struct unary_function;
template<class Arg1, class Arg2, class Result>
struct binary_function;
template<class T>
struct plus;
template<class T>
struct minus;
template<class T>
struct multiplies;
template<class T>
struct divides;
template<class T>
struct modulus;
template<class T>
struct negate;
template<class T>
struct equal_to;
template<class T>
struct not_equal_to;
template<class T>
struct greater;
template<class T>
struct less;
template<class T>
struct greater_equal;
template<class T>
struct less_equal;
template<class T>
struct logical_and;
template<class T>
struct logical_or;
template<class T>
struct logical_not;
template<class Pred>
struct unary_negate;
template<class Pred>
struct binary_negate;
template<class Pred>
class binder1st;
template<class Pred>
class binder2nd;
template<class Arg, class Result>
class pointer_to_unary_function;
template<class Arg1, class Arg2, class Result>
class pointer_to_binary_function;
template<class R, class T>
struct mem_fun_t;
template<class R, class T, class A>
struct mem_fun1_t;
template<class R, class T>
struct mem_fun_ref_t;
template<class R, class T, class A>
struct mem_fun1_ref_t;
// TEMPLATE FUNCTIONS
template<class Pred>
unary_negate<Pred> not1(const Pred& pr);
template<class Pred>
binary_negate<Pred> not2(const Pred& pr);
template<class Pred, class T>
binder1st<Pred> bind1st(const Pred& pr, const T& x);
template<class Pred, class T>
binder2nd<Pred> bind2nd(const Pred& pr, const T& x);
template<class Arg, class Result>
pointer_to_unary_function<Arg, Result>
ptr_fun(Result (*)(Arg));
template<class Arg1, class Arg2, class Result>
pointer_to_binary_function<Arg1, Arg2, Result>
ptr_fun(Result (*)(Arg1, Arg2));
template<class R, class T>
mem_fun_t<R, T> mem_fun(R (T::*pm)());
template<class R, class T, class A>
mem_fun1_t<R, T, A> mem_fun1(R (T::*pm)(A arg));
template<class R, class T>
mem_fun_ref_t<R, T> mem_fun_ref(R (T::*pm)());
template<class R, class T, class A>
mem_fun1_ref_t<R, T, A>
mem_fun1_ref(R (T::*pm)(A arg));
};
Include the STL
standard header <functional> to define
several templates that help construct function objects, objects of a
type that defines operator(). A function object can
thus be a function pointer, but in the more general case the
object can store additional information that can be used during a
function call.
binary_functiontemplate<class Arg1, class Arg2, class Result>
struct binary_function {
typedef Arg1 first_argument_type;
typedef Arg2 second_argument_type;
typedef Result result_type;
};
The template class serves as a base for classes that define a member function of the form:
result_type operator()(first_argument_type,
second_argument_type)
Hence, all such binary functions
can refer to their first argument type as first_argument_type,
their second argument type as second_argument_type,
and their return type as result_type.
binary_negatetemplate<class Pred>
class binary_negate
: public binary_function<
typename Pred::first_argument_type,
typename Pred::second_argument_type, bool> {
public:
explicit binary_negate(const Pred& pr);
bool operator()(
const typename Pred::first_argument_type& x,
const typename Pred::second_argument_type& y) const;
};
The template class stores a copy of pr, which
must be a binary function
object. It defines its member function operator()
as returning !pr(x, y).
bind1sttemplate<class Pred, class T>
binder1st<Pred> bind1st(const Pred& pr, const T& x);
The function returns binder1st<Pred>(pr,
typename Pred::first_argument_type(x)).
bind2ndtemplate<class Pred, class T>
binder2nd<Pred> bind2nd(const Pred& pr, const T& y);
The function returns binder2nd<Pred>(pr,
typename Pred::second_argument_type(y)).
binder1sttemplate<class Pred>
class binder1st
: public unary_function<
typename Pred::second_argument_type,
typename Pred::result_type> {
public:
typedef typename Pred::second_argument_type argument_type;
typedef typename Pred::result_type result_type;
binder1st(const Pred& pr,
const typename Pred::first_argument_type& x);
result_type operator()(const argument_type& y) const;
protected:
Pred op;
typename Pred::first_argument_type value;
};
The template class stores a copy of pr, which
must be a binary function
object, in op,
and a copy of x in value.
It defines its member function operator() as
returning op(value, y).
binder2ndtemplate<class Pred>
class binder2nd
: public unary_function<
typename Pred::first_argument_type,
typename Pred::result_type> {
public:
typedef typename Pred::first_argument_type argument_type;
typedef typename Pred::result_type result_type;
binder2nd(const Pred& pr,
const typename Pred::second_argument_type& y);
result_type operator()(const argument_type& x) const;
protected:
Pred op;
typename Pred::second_argument_type value;
};
The template class stores a copy of pr, which
must be a binary function
object, in op,
and a copy of y in value.
It defines its member function operator() as
returning op(x, value).
dividestemplate<class T>
struct divides : public binary_function<T, T, T> {
T operator()(const T& x, const T& y) const;
};
The template class defines its member function as returning x
/ y.
equal_totemplate<class T>
struct equal_to
: public binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const;
};
The template class defines its member function as returning x
== y.
greatertemplate<class T>
struct greater : public binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const;
};
The template class defines its member function as returning x
> y. The member function defines a total ordering, even if T
is an object pointer type.
greater_equaltemplate<class T>
struct greater_equal
: public binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const;
};
The template class defines its member function as returning x
>= y. The member function defines a total ordering, even if T
is an object pointer type.
lesstemplate<class T>
struct less : public binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const;
};
The template class defines its member function as returning x
< y. The member function defines a total ordering, even if T
is an object pointer type.
less_equaltemplate<class T>
struct less_equal
: public binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const;
};
The template class defines its member function as returning x
<= y. The member function defines a total ordering, even if T
is an object pointer type.
logical_andtemplate<class T>
struct logical_and
: public binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const;
};
The template class defines its member function as returning x
&& y.
logical_nottemplate<class T>
struct logical_not : public unary_function<T, bool> {
bool operator()(const T& x) const;
};
The template class defines its member function as returning !x.
logical_ortemplate<class T>
struct logical_or
: public binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const;
};
The template class defines its member function as returning x
|| y.
mem_funtemplate<class R, class T>
mem_fun_t<R, T> mem_fun(R (T::*pm)());
The template function returns mem_fun_t<R, T>(pm).
mem_fun_ttemplate<class R, class T>
struct mem_fun_t : public unary_function<T *, R> {
explicit mem_fun_t(R (T::*pm)());
R operator()(T *p) const;
};
The template class stores a copy of pm, which
must be a pointer to a member function of class T,
in a private member object. It defines its member function operator()
as returning (p->*pm)().
mem_fun_reftemplate<class R, class T>
mem_fun_ref_t<R, T> mem_fun_ref(R (T::*pm)());
The template function returns mem_fun_ref_t<R,
T>(pm).
mem_fun_ref_ttemplate<class R, class T>
struct mem_fun_ref_t
: public unary_function<T *, R> {
explicit mem_fun_t(R (T::*pm)());
R operator() const(T& x);
};
The template class stores a copy of pm, which
must be a pointer to a member function of class T,
in a private member object. It defines its member function operator()
as returning (x.*Pm)().
mem_fun1template<class R, class T, class A>
mem_fun1_t<R, T, A> mem_fun1(R (T::*pm)(A));
The template function returns mem_fun1_t<R, T,
A>(pm).
mem_fun1_ttemplate<class R, class T, class A>
struct mem_fun1_t
: public binary_function<T *, A, R> {
explicit mem_fun1_t(R (T::*pm)(A));
R operator() const(T *p, A arg);
};
The template class stores a copy of pm, which
must be a pointer to a member function of class T,
in a private member object. It defines its member function operator()
as returning (p->*pm)(arg).
mem_fun1_reftemplate<class R, class T, class A>
mem_fun1_ref_t<R, T, A> mem_fun1_ref(R (T::*pm)(A));
The template function returns mem_fun1_ref_t<R,
T, A>(pm).
mem_fun1_ref_ttemplate<class R, class T, class A>
struct mem_fun1_ref_t
: public binary_function<T *, A, R> {
explicit mem_fun1_ref_t(R (T::*pm)(A));
R operator() const(T& x, A arg);
};
The template class stores a copy of pm, which
must be a pointer to a member function of class T,
in a private member object. It defines its member function operator()
as returning (x.*pm)(arg).
minustemplate<class T>
struct minus : public binary_function<T, T, T> {
T operator()(const T& x, const T& y) const;
};
The template class defines its member function as returning x
- y.
modulustemplate<class T>
struct modulus : public binary_function<T, T, T> {
T operator()(const T& x, const T& y) const;
};
The template class defines its member function as returning x
% y.
multipliestemplate<class T>
struct multiplies : public binary_function<T, T, T> {
T operator()(const T& x, const T& y) const;
};
The template class defines its member function as returning x
* y.
negatetemplate<class T>
struct negate : public unary_function<T, T> {
T operator()(const T& x) const;
};
The template class defines its member function as returning -x.
not1template<class Pred>
unary_negate<Pred> not1(const Pred& pr);
The template function returns unary_negate<Pred>(pr).
not2template<class Pred>
binary_negate<Pred> not2(const Pred& pr);
The template function returns binary_negate<Pred>(pr).
not_equal_totemplate<class T>
struct not_equal_to
: public binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const;
};
The template class defines its member function as returning x
!= y.
plustemplate<class T>
struct plus : public binary_function<T, T, T> {
T operator()(const T& x, const T& y) const;
};
The template class defines its member function as returning x
+ y.
pointer_to_binary_functiontemplate<class Arg1, class Arg2, class Result>
class pointer_to_binary_function
: public binary_function<Arg1, Arg2, Result> {
public:
explicit pointer_to_binary_function(
Result (*pf)(Arg1, Arg2));
Result operator()(const Arg1 x, const Arg2 y) const;
};
The template class stores a copy of pf. It
defines its member function operator() as
returning (*pf)(x, y).
pointer_to_unary_functiontemplate<class Arg, class Result>
class pointer_to_unary_function
: public unary_function<Arg, Result> {
public:
explicit pointer_to_unary_function(
Result (*pf)(Arg));
Result operator()(const Arg x) const;
};
The template class stores a copy of pf. It
defines its member function operator() as
returning (*pf)(x).
ptr_funtemplate<class Arg, class Result>
pointer_to_unary_function<Arg, Result>
ptr_fun(Result (*pf)(Arg));
template<class Arg1, class Arg2, class Result>
pointer_to_binary_function<Arg1, Arg2, Result>
ptr_fun(Result (*pf)(Arg1, Arg2));
The first template function returns pointer_to_unary_function<Arg,
Result>(pf).
The second template function returns pointer_to_binary_function<Arg1,
Arg2, Result>(pf).
unary_functiontemplate<class Arg, class Result>
struct unary_function {
typedef Arg argument_type;
typedef Result result_type;
};
The template class serves as a base for classes that define a member function of the form:
result_type operator()(argument_type)
Hence, all such unary functions
can refer to their sole argument type as argument_type
and their return type as
result_type.
unary_negatetemplate<class Pred>
class unary_negate
: public unary_function<
typename Pred::argument_type,
bool> {
public:
explicit unary_negate(const Pred& pr);
bool operator()(
const typename Pred::argument_type& x) const;
};
The template class stores a copy of pr, which
must be a unary function
object. It defines its member function operator()
as returning !pr(x).
See also the Table of Contents .
Copyright © 1992-1996 by P.J. Plauger. Portions derived from work copyright © 1994 by Hewlett-Packard Company. All rights reserved.