Boost logo

Boost Users :

From: Jack M. Thompson (JMThompson_at_[hidden])
Date: 2002-01-23 23:29:28


 
 
I've tried trying to figure that out too. I think what we are looking
for is an adapter. I think you want to base your target object either
on a unary_function or binary_function, but you don't have to. And I
think that you need to use binders. But I don't know how.
 
-JMT
 
-----Original Message-----
From: Duane Murphy [mailto:duanemurphy_at_[hidden]]
Sent: Wednesday, January 23, 2002 4:36 PM
To: Boost Users
Subject: [Boost-Users] mem_fn and references?
 
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

Info: <http://www.boost.org>
Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>

Your use of Yahoo! Groups is subject to the Yahoo!
<http://docs.yahoo.com/info/terms/> Terms of Service.

[Non-text portions of this message have been removed]


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