- I wonder, if the objects generated with "new" are deleted correctly with this concept.
- I fail to use "bind" instead of "bind2nd". How do I do this?
- Last question: how do I do the same with a lambda term instead of a named function?
Why do I use list? I decided to take a list instead of a vector because my objects are not sequenced. At the very end I want to bring some "waterfall like" code to object oriented, basically because of performance issues (you will see the problems here), so I need a concept, where I have fast access to objects in hierarchies of containers and let them communicate with each other, and that is fast too. Maybe think of a modular synthesizer.
class Layer {
private:
string name;
bool active;
public:
Layer();
Layer(string m_name, bool m_active);
bool isName(string m_name);
};
// ... constructors
bool Layer::isName(string m_name) {
return name == m_name;
}
class Stack {
public:
list<Layer*> layer;
list<Layer*>::iterator iter;
};
int main() {
Stack stack;
stack.layer.push_back(new Layer);
stack.layer.push_back(new Layer("snail", true));
stack.layer.push_back(new Layer("squirrel", false));
string search = "snail";
stack.layer.remove_if(bind2nd(mem_fun(&Layer::isName), search));
return 0;
}