Boost logo

Boost Users :

From: Nico Galoppo (nico_at_[hidden])
Date: 2006-02-25 17:31:08


Hi,

is there some utility (templated) adapter type class that I could use to
construct an adapter such that an (associative) array of (pointers to) objects
behaves like an (associative) array of a member variable of the objects?
Something like

class A {
   int val;
};

std::map<int, shared_ptr<A> > container_type;
container_type amap;

shared_ptr<A> elem(new A());

amap[2] = elem;
amap[4] = elem;
amap[6] = elem;

selector_adapter<container_type, &A::val> val_container(&amap);
std::cout << val_container[4]; // should output amap[4]->val;

--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