M
Mark A. Gibbs
good day,
i'm not sure if i'm using the standard function adaptors correctly. i
want to use a member function in a call to transform(), but not a member
function of the class being transformed.
i have:
class B {};
class C {};
class A
{
public:
virtual C foo(B);
};
C A::foo(B)
{
return C();
}
A const& a = /*initialized somehow, so may be a child of A*/;
vector<B> in(42, B());
vector<C> out(in.length(), C());
transform(in.begin(), in.end(), out.begin(), /*what do i do here?*/);
i want to call a.foo() for each member of in. i was thinking of:
bind1st(ptr_fun(&A::foo), &a);
or something like that, but i don't think that's kosher. there must be a
simple way to do this. i could write a helper function object to do it,
but i was wondering if there is already a way?
--
Mark A. Gibbs (aka. Indi)
Administrator
#c++ on irc.Rizon.net
http://ca.geocities.com/[email protected]/
(temporary website)
i'm not sure if i'm using the standard function adaptors correctly. i
want to use a member function in a call to transform(), but not a member
function of the class being transformed.
i have:
class B {};
class C {};
class A
{
public:
virtual C foo(B);
};
C A::foo(B)
{
return C();
}
A const& a = /*initialized somehow, so may be a child of A*/;
vector<B> in(42, B());
vector<C> out(in.length(), C());
transform(in.begin(), in.end(), out.begin(), /*what do i do here?*/);
i want to call a.foo() for each member of in. i was thinking of:
bind1st(ptr_fun(&A::foo), &a);
or something like that, but i don't think that's kosher. there must be a
simple way to do this. i could write a helper function object to do it,
but i was wondering if there is already a way?
--
Mark A. Gibbs (aka. Indi)
Administrator
#c++ on irc.Rizon.net
http://ca.geocities.com/[email protected]/
(temporary website)