From a0173a4a4596037bfe7f5866c72f9bd25d424352 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 9 Dec 2012 12:06:19 +0100 Subject: Do not presume the use of shared_ptr. --- cells-test.cpp | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'cells-test.cpp') diff --git a/cells-test.cpp b/cells-test.cpp index 1b9147b..a88fe5b 100644 --- a/cells-test.cpp +++ b/cells-test.cpp @@ -27,35 +27,28 @@ using std::cout; using std::endl; typedef formula_cell fcell; -typedef shared_ptr sfcell; typedef formula_cell ucell; -typedef shared_ptr sucell; int main(int argc, char** argv) { - sfcell x0 = fcell::make(); - sfcell x1 = fcell::make(); - sfcell x2 = fcell::make(); - sfcell y = fcell::make(); - sfcell z = fcell::make(); - sucell a = ucell::make(); - sucell b = ucell::make(); + fcell x0, x1, x2, y, z; + ucell a, b; - with_transaction([=](){ - x0->reset(10); - x1->reset([=](){ return *x0 + 5; }); - x2->reset([=](){ return *x0 * 2; }); - y->reset([=](){ return *x1 * *x2; }); - z->reset([=](){ return *x0 * *y; }); - a->reset([=]() -> unit { cout << "z is now " << *z << "." << endl; return unit(); }); - b->reset([=]() -> unit { cout << "x2 is now " << *x2 << "." << endl; return unit(); }); + with_transaction([&](){ + x0.reset(10); + x1.reset([&](){ return *x0 + 5; }); + x2.reset([&](){ return *x0 * 2; }); + y.reset([&](){ return *x1 * *x2; }); + z.reset([&](){ return *x0 * *y; }); + a.reset([&]() -> unit { cout << "z is now " << *z << "." << endl; return unit(); }); + b.reset([&]() -> unit { cout << "x2 is now " << *x2 << "." << endl; return unit(); }); }); - x0->reset(15); - x0->reset(-20); - y->reset(-3); - x1->reset([=]() { return (double)*x0; }); - y->reset([=]() { return *x1 + *x2; }); + x0.reset(15); + x0.reset(-20); + y.reset(-3); + x1.reset([&]() { return (double)*x0; }); + y.reset([&]() { return *x1 + *x2; }); return EXIT_SUCCESS; } -- cgit v1.2.3