FBB::FnWrap1

FBB::FnWrap1

libbobcat1-dev_2.02.03-x.tar.gz

2005-2009


FBB::FnWrap1(3bobcat)

FBB::FnWrap1(3bobcat)

libbobcat1-dev_2.02.03-x.tar.gz Unary FnWrapper

2005-2009

NAME

FBB::FnWrap1 - STL unary argument wrapper template class

SYNOPSIS

#include <bobcat/fnwrap1>

DESCRIPTION

The FBB::FnWrap1 class is a configurable unary argument wrapper template class. Its primary use is in combination with the generic algorithms of the standard template libray.

The callled function itself may be specified as one of the constructor's arguments. It must be a (static member) function. Using a (static member) function has various advantages, especially with the FnWrap?c classes to which a local context can be passed:

The FBB::FnWrap1 template class has the following template parameters:

NAMESPACE

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS FROM

-

CONSTRUCTOR

OVERLOADED OPERATOR

In normal situations the following member function will call the function that is passed to FBB::FnWrap1's constructor. See the example below.

TYPEDEFS

The class defines two types, which are used by generic algorithms:

EXAMPLES


    #include <algorithm>
    #include <iostream>
    #include <vector>
    #include <string>
    #include <bobcat/fnwrap1>
    
    using namespace std;
    using namespace FBB;
    
    bool cmp(string &actual)    // modifies `actual'
    {
        cout << "Saw " << actual << endl;
        bool ret = actual == "hello";
        actual += ".";
        return ret;
    }
    
    class X
    {
        public:
                                // merely inspects `actual'
            static bool cmp(string const &actual)
            {
                cout << "Saw " << actual << endl;
                return actual == "hello";
            }
    };
    
    int main(int argc, char **argv)
    {
        vector<string> vs(argv, argv + argc);
    
        vector<string>::iterator it;
    
        it = find_if(vs.begin(), vs.end(),
            FnWrap1<string &, bool>(&cmp));
    
        if (it != vs.end())
            cout << "At " << *it << endl;
    
        cout << endl;
    
        it = find_if(vs.begin(), vs.end(),
            FnWrap1<string const &, bool>(&X::cmp));
    
        if (it != vs.end())
            cout << "At " << *it << endl;
    
    }
        
After compilation and linking, the program could be called as follows:

    a.out one two hello three hello four
        

FILES

bobcat/fnwrap1 - defines the class interface

SEE ALSO

bobcat(7), fnwrap1c(3bobcat), fnwrap2(3bobcat), fnwrap2c(3bobcat), foreach(3bobcat), repeat(3bobcat)

BUGS

None Reported.

DISTRIBUTION FILES

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).