Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

pointer_to_unary_function Class

Converts a unary function pointer into an adaptable unary function.

template<class Arg, class Result>
class pointer_to_unary_function
    : public unary_function<Arg, Result> 
    {
    public:
        explicit pointer_to_unary_function(
            Result (*_pfunc)(Arg)
        );
        Result operator()(
            Arg _Left
        ) const;
    };
_pfunc

The binary function to be converted.

_Left

The object that the *_pfunc is called on.

The template class stores a copy of _pfunc. It defines its member function operator() as returning (*_pfunc)(_Left).

A unary function pointer is a function object and may be passed to any Standard Template Library algorithm that is expecting a unary function as a parameter, but it is not adaptable. To use it with an adaptor, such as binding a value to it or using it with a negator, it must be supplied with the nested types argument_type and result_type that make such an adaptation possible. The conversion by pointer_to_unary_function allows the function adaptors to work with binary function pointers.

The constructor of pointer_to_unary_function is rarely used directly. See the helper function ptr_fun for an example of how to declare and use the pointer_to_unary_function adaptor predicate.

Header: <functional>

Namespace: std

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.