Smart properties and data structures.
using namespace std;
#include <iostream>
#include <list>
#include "../AMProperty.h"
using namespace AMSmartProperties;
using namespace std;
int main(int argc, char **argv) {
AMPropertyPool pool;
std::list<AMProperty<int> > myList;
for(int i=0; i < 10; i++) {
AMProperty<int> value(pool, i+1);
myList.push_back(value);
}
AMProperty<int> sum(pool, [&] {
int sum = 0;
for(std::list<AMProperty<int> >::iterator it = myList.begin(); it != myList.end(); it++) {
sum += (int)*it;
}
return sum;
});
cout << "sum1 =" << sum() << endl;
std::list<AMProperty<int> >::iterator it = myList.begin();
std::advance(it, 4);
*it = 25;
cout << "sum2 =" << sum() << endl;
}