FBB::FnWrap2

FBB::FnWrap2

libbobcat1-dev_2.02.03-x.tar.gz

2005-2009


FBB::FnWrap2(3bobcat)

FBB::FnWrap2(3bobcat)

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

2005-2009

NAME

FBB::FnWrap2 - STL binary argument wrapper template class

SYNOPSIS

#include <bobcat/fnwrap2>

DESCRIPTION

The FBB::FnWrap2 class is a configurable binary 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::FnWrap2 template class has the following template parameters:

NAMESPACE

FBB

INHERITS FROM

-

CONSTRUCTOR

OVERLOADED OPERATOR

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

TYPEDEFS

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

EXAMPLES


    #include <algorithm>
    #include <iostream>
    #include <vector>
    #include <string>
    #include <functional>
    
    #include <bobcat/fnwrap2>
    
    using namespace std;
    using namespace FBB;
    
    bool cmp(string &actual, string const &target)
    {
        cout << "Saw " << actual << endl;
    
        bool ret = actual == target;
        actual += ".";
        return ret;
    }
    
    class X
    {
        public:
            static bool cmp(string const &actual, string const &target)
            {
                cout << "Saw " << actual << endl;
                return actual == target;
            }
    };
    
    int main(int argc, char **argv)
    {
        vector<string> vs(argv, argv + argc);
    
        find_if(
            vs.begin(), vs.end(),
            bind2nd(
                FnWrap2<string &, string const &, bool>(&cmp), 
                string("hello")
            )
        );
    
        cout << endl;
    
        find_if(
            vs.begin(), vs.end(),
            bind2nd(
                FnWrap2<string const &, string const &, bool>(&X::cmp), 
                string("hello")
            )
        );
    }
        
After compilation and linking, the program could be called as follows:

    a.out one two hello three hello four
        

FILES

bobcat/fnwrap2 - defines the class interface

SEE ALSO

bobcat(7), fnwrap1(3bobcat), fnwrap1c(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).