Boost logo

Boost Users :

From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2002-01-23 19:35:48


I am trying to make a member function call to all objects returned by an
iterator. mem_fn is giving me an error when trying to call get_pointer()
for a reference object. There is no overload for get_pointer of a
reference object. Is there some reason or should I be doing this differently.

The long description is that I am iterating over a container of objects.
I would like to make a member function call on each of these objects.
Then I get an error that there is no matching function for get_pointer(
obj ). I have solved this by providing my own get_pointer() overload
specifically for obj to prevent any bad things from happening until I can
found out what the real problem is.

Here is some pseudo code to get things in the right orientation.

class obj
{
public:
    void method();
};

class obj_iterator
{
public:
    obj& iterator::operator*() const { return obj_; }
};

class obj_container
{
public:
    obj_iterator begin();
    obj_iterator end();
}

{
    ...
    obj_container c;
    foreach( c.begin(), c.end(), mem_fn( method ) );
}

Thanks,
 ...Duane


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net