Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.
PrevUpHomeNext

Binding Member Functions

#include <boost/phoenix/bind/bind_member_function.hpp>

Binding member functions can be done similarly. A bound member function takes in a pointer or reference to an object as the first argument. For instance, given:

struct xyz
{
    void foo(int) const;
};

xyz's foo member function can be bound as:

bind(&xyz::foo, obj, arg1) // obj is an xyz object

Take note that a lazy-member functions expects the first argument to be a pointer or reference to an object. Both the object (reference or pointer) and the arguments can be lazily bound. Examples:

xyz obj;
bind(&xyz::foo, arg1, arg2)     // arg1.foo(arg2)
bind(&xyz::foo, obj, arg1)      // obj.foo(arg1)
bind(&xyz::foo, obj, 100)       // obj.foo(100)

PrevUpHomeNext