Boost logo

Boost Users :

From: Nico Galoppo (nico_at_[hidden])
Date: 2006-03-30 00:31:58


Hi Stuart,

thanks for your answer.

Stuart Dootson wrote:
> void f(int& membervar)
> {
> membervar = 3;
> }
>
> A a;
> f(a.value);

Well, I probably over-simplified the problem. What I would really like to do is
manipulate data members of all instances in a container, where the data member
is given as an input parameter.

struct A {
  int value;
  int othervalue;
}

container<A> array;

void f(container<A> & array, membervarref)
{
   BOOST_FOREACH(container<A>::value_type& element, array)
         bind(membervarref, element) = 3;
}

f(array, &A::value);
f(array, &A::othervalue);

--nico

-- 
nico galoppo von borries     @  address: 105 creel st., chapel hill
comp. graphics phd. student  @           north carolina, 27516 USA
UNC, chapel hill             @  phone: +1 (919) 962-1898 (office)
                              @         +1 (919) 942-7609 (home)
                              @  email: nico at cs dot unc dot edu
                              @  homepage: http://www.cs.unc.edu/~nico
--- debian linux :: vim powered

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